/* ============================================================
   三井田家ウォレット 共通スタイル
   - 親しみやすい和文 (Zen Maru Gothic) + 上品な欧文 (DM Serif Display)
   - 玩具的にしない、本格派の練習機としての風格
   ============================================================ */

:root {
    --bg:          #FAF7F2;
    --surface:    #FFFFFF;
    --surface-2:  #F4F0EA;
    --ink:        #1F2937;
    --ink-soft:   #4B5563;
    --ink-mute:   #9CA3AF;
    --line:       #E5E0D8;
    --line-soft:  #EFEAE2;
    --brand:      #2C5F4A;       /* 落ち着いた深緑 */
    --brand-ink:  #FFFFFF;
    --brand-soft: #E8F0EC;
    --accent:     #C9923E;       /* 上品なゴールド */
    --danger:     #B0413E;
    --danger-soft: #FBEBEA;
    --warn:       #C77F2C;
    --ok:         #2F7A4B;
    --ok-soft:    #E4F0E9;
    --shadow-sm:  0 1px 2px rgba(31,41,55,0.06);
    --shadow-md:  0 4px 16px rgba(31,41,55,0.08);
    --radius:     12px;
    --radius-sm:  8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: 'Zen Maru Gothic', 'Hiragino Maru Gothic ProN', 'Yu Gothic', system-ui, -apple-system, sans-serif;
    font-weight: 500;
    font-size: 16px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
    margin: 0 0 0.6em;
    font-weight: 700;
    line-height: 1.4;
}
h1 { font-size: 1.6rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }

.brand-serif {
    font-family: 'DM Serif Display', 'Times New Roman', serif;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* ------- Layout ------- */
.wrap {
    max-width: 880px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}
.wrap-narrow {
    max-width: 520px;
    margin: 0 auto;
    padding: 48px 20px 80px;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 16px 24px;
}
.site-header-inner {
    max-width: 880px;
    margin: 0 auto;
    display: flex;
    align-items: baseline;
    gap: 16px;
}
.site-header .logo {
    font-family: 'DM Serif Display', serif;
    font-size: 1.4rem;
    color: var(--brand);
    margin: 0;
}
.site-header .logo-sub {
    color: var(--ink-mute);
    font-size: 0.85rem;
}
.site-header .right {
    margin-left: auto;
    color: var(--ink-mute);
    font-size: 0.85rem;
}

/* ------- Card ------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 32px;
    margin-bottom: 24px;
}
.card-tight { padding: 20px 24px; }

/* ------- Form ------- */
.form-row {
    margin-bottom: 18px;
}
.form-row label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--ink);
}
.form-row .hint {
    font-size: 0.85rem;
    color: var(--ink-mute);
    margin-top: 4px;
    line-height: 1.5;
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(44,95,74,0.12);
}
textarea { min-height: 80px; resize: vertical; }

.form-row.short input { max-width: 260px; }
.form-row.tiny input  { max-width: 120px; }

/* ------- Buttons ------- */
.btn {
    display: inline-block;
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--brand);
    color: var(--brand-ink);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, transform .05s;
}
.btn:hover { background: #25503e; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-ghost {
    background: transparent;
    color: var(--brand);
    border-color: var(--brand);
}
.btn-ghost:hover { background: var(--brand-soft); }
.btn-mute {
    background: var(--surface-2);
    color: var(--ink-soft);
    border-color: var(--line);
}
.btn-mute:hover { background: #ebe6dc; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #952f2d; }

.btn-row {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-top: 28px;
}
.btn-row.right { justify-content: flex-end; }

/* ------- Stepper ------- */
.stepper {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 28px;
    padding: 0;
    list-style: none;
}
.stepper li {
    flex: 1 1 60px;
    min-width: 60px;
    text-align: center;
    padding: 6px 4px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-mute);
    font-size: 0.78rem;
    line-height: 1.3;
}
.stepper li .num {
    display: block;
    font-family: 'DM Serif Display', serif;
    font-size: 1.1rem;
    color: var(--ink-mute);
    margin-bottom: 2px;
}
.stepper li.done {
    border-color: var(--ok);
    background: var(--ok-soft);
    color: var(--ok);
}
.stepper li.done .num { color: var(--ok); }
.stepper li.current {
    border-color: var(--brand);
    background: var(--brand);
    color: var(--brand-ink);
}
.stepper li.current .num { color: var(--brand-ink); }

/* ------- Admin navigation ------- */
.admin-nav {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
}
.admin-nav-inner {
    max-width: 880px;
    margin: 0 auto;
    display: flex;
    gap: 4px;
    padding: 6px 12px;
}
.admin-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    white-space: nowrap;
    transition: background .12s, color .12s;
}
.admin-nav-link:hover {
    text-decoration: none;
    background: var(--brand-soft);
    color: var(--brand);
}
.admin-nav-link.active {
    background: var(--brand);
    color: var(--brand-ink);
}
.admin-nav-badge {
    display: inline-block;
    background: var(--danger);
    color: #fff;
    border-radius: 999px;
    font-size: 0.72rem;
    padding: 1px 7px;
    line-height: 1.5;
    min-width: 18px;
    text-align: center;
}
.admin-nav-link.active .admin-nav-badge {
    background: rgba(255,255,255,0.25);
}

/* ------- Kids navigation (simpler) ------- */
.kid-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}
.kid-nav a {
    flex: 1 1 120px;
    text-align: center;
    padding: 14px 10px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
}
.kid-nav a:hover { text-decoration: none; border-color: var(--brand); }

/* ------- Transaction list ------- */
.tx-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.tx-list li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 16px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--line-soft);
}
.tx-list li:last-child { border-bottom: 0; }
.tx-list .tx-when {
    color: var(--ink-mute);
    font-size: 0.78rem;
    grid-column: 1 / 2;
    grid-row: 2;
}
.tx-list .tx-title {
    font-weight: 700;
    grid-column: 1;
    grid-row: 1;
}
.tx-list .tx-reason {
    color: var(--ink-soft);
    font-size: 0.85rem;
    margin-top: 2px;
    grid-column: 1;
    grid-row: 3;
}
.tx-list .tx-amount {
    grid-column: 2;
    grid-row: 1 / 3;
    align-self: center;
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.tx-list .tx-amount.up   { color: var(--ok); }
.tx-list .tx-amount.down { color: var(--danger); }
.tx-list .tx-balance {
    color: var(--ink-mute);
    font-size: 0.75rem;
    grid-column: 2;
    grid-row: 3;
    text-align: right;
}

/* ------- Filter bar ------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 18px;
}
.filter-bar .form-row { margin-bottom: 0; }

/* ------- Pagination ------- */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 18px;
}
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.88rem;
}
.pagination .current {
    background: var(--brand);
    color: var(--brand-ink);
    border-color: var(--brand);
}

/* ------- Portfolio donut ------- */
.portfolio {
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
}
.donut-wrap {
    position: relative;
    width: 180px;
    height: 180px;
    flex-shrink: 0;
}
.donut {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    /* 各色は inline style の conic-gradient で指定 */
}
.donut-hole {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    border-radius: 50%;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}
.donut-hole .total-label { font-size: 0.78rem; color: var(--ink-mute); }
.donut-hole .total-value {
    font-family: 'DM Serif Display', serif;
    font-size: 1.5rem;
    color: var(--ink);
    line-height: 1.1;
}
.donut-legend {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1 1 200px;
    min-width: 180px;
}
.donut-legend li {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--line-soft);
    font-size: 0.92rem;
}
.donut-legend li:last-child { border-bottom: 0; }
.donut-legend .swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}
.donut-legend .name { flex: 1; }
.donut-legend .val  { font-weight: 700; font-variant-numeric: tabular-nums; }
.donut-legend .pct  { color: var(--ink-mute); font-size: 0.82rem; margin-left: 8px; min-width: 48px; text-align: right; }

/* ------- Compound interest simulator ------- */
.compound-sim {
    background: var(--brand-soft);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border: 1px solid var(--brand);
    margin-top: 16px;
}
.compound-sim h4 { margin: 0 0 6px; font-size: 0.95rem; color: var(--brand); }
.compound-sim p  { margin: 0; line-height: 1.7; }
.compound-sim strong { font-family: 'DM Serif Display', serif; font-size: 1.15rem; }

/* ------- Price change indicator ------- */
.price-change {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 700;
    margin-top: 2px;
    letter-spacing: 0.02em;
}
.price-change.up   { color: var(--ok); }
.price-change.down { color: var(--danger); }
.price-change.flat { color: var(--ink-mute); font-weight: 500; }

/* 検査リスト中で価格と前日比を縦に並べる用 */
.check-mark.price {
    width: auto;
    min-width: 110px;
    text-align: right;
    line-height: 1.3;
}
.check-mark.price .price-now {
    font-weight: 700;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

/* ------- Alerts ------- */
.alert {
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin: 0 0 18px;
    background: var(--surface-2);
    line-height: 1.6;
}
.alert.alert-ok      { background: var(--ok-soft);     border-color: var(--ok);     color: #1f5a36; }
.alert.alert-danger  { background: var(--danger-soft); border-color: var(--danger); color: #6b2421; }
.alert.alert-info    { background: var(--brand-soft);  border-color: var(--brand);  color: #1f4537; }
.alert.alert-warn    { background: #FBF3E2;            border-color: var(--warn);   color: #6e4513; }

.alert h3 { margin-top: 0; font-size: 1rem; }

/* ------- Check list (env check) ------- */
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list li {
    display: flex;
    align-items: baseline;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line-soft);
}
.check-list li:last-child { border-bottom: 0; }
.check-list .check-name { flex: 1; }
.check-list .check-detail { color: var(--ink-mute); font-size: 0.85rem; }
.check-list .check-mark {
    font-weight: 700;
    width: 80px;
    text-align: right;
}
.check-list .check-mark.ok   { color: var(--ok); }
.check-list .check-mark.ng   { color: var(--danger); }
.check-list .check-mark.warn { color: var(--warn); }

/* ------- Login cards ------- */
.login-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 24px;
}
.login-card {
    display: block;
    padding: 20px 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-align: center;
    color: var(--ink);
    text-decoration: none;
    transition: transform .1s, box-shadow .1s, border-color .1s;
}
.login-card:hover {
    text-decoration: none;
    border-color: var(--brand);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.login-card .avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--brand-soft);
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--brand);
    font-weight: 700;
    font-family: 'DM Serif Display', serif;
}
.login-card .name {
    font-weight: 700;
    margin-bottom: 4px;
}
.login-card .role {
    font-size: 0.8rem;
    color: var(--ink-mute);
}

/* ------- Tiny utility ------- */
.muted { color: var(--ink-mute); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mt-24 { margin-top: 24px; }
.mb-24 { margin-bottom: 24px; }
.divider {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 24px 0;
}
.kbd {
    font-family: 'SF Mono', Consolas, monospace;
    background: var(--surface-2);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
}
pre.code {
    background: #1F2937;
    color: #E5E7EB;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
}

/* ------- PIN input ------- */
.pin-input {
    letter-spacing: 0.8em;
    text-align: center;
    font-size: 1.4rem;
    font-family: 'DM Serif Display', serif;
}

/* ------- Color swatch ------- */
.color-swatch {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}
.color-swatch label {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    position: relative;
}
.color-swatch input { position: absolute; opacity: 0; }
.color-swatch input:checked + span {
    box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--brand);
}
.color-swatch span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

/* ------- Footer ------- */
.site-footer {
    text-align: center;
    color: var(--ink-mute);
    font-size: 0.8rem;
    padding: 24px;
    border-top: 1px solid var(--line);
    background: var(--surface);
}

@media (max-width: 640px) {
    .card { padding: 22px 18px; }
    h1 { font-size: 1.35rem; }
    .stepper li { font-size: 0.68rem; }
    .btn-row { flex-direction: column-reverse; gap: 10px; }
    .btn-row .btn { width: 100%; }
}
