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

:root {
    --bg: #ffffff;
    --bg-alt: #f1f3f4;
    --fg: #202124;
    --muted: #5f6368;
    --line: #e8eaed;
    --primary: #01875f;
    --primary-hover: #017048;
    --link: #1a73e8;
    --danger: #d93025;
    --warn: #fbbc04;
    --green: #34a853;
    --plus: #137333;
    --minus: #d93025;
}

html { scroll-behavior: smooth; }

body {
    font-family: 'Google Sans', 'Roboto', 'Segoe UI', 'Helvetica Neue', Arial,
        'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
    background-color: var(--bg);
    color: var(--fg);
    line-height: 1.55;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

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

code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.92em; }

/* ===== topbar ===== */
.topbar {
    position: sticky;
    top: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    z-index: 100;
}
.topbar-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    max-width: 1280px;
    margin: 0 auto;
    padding: 10px 24px;
}
.brand { color: var(--fg); font-size: 20px; font-weight: 400; }
.brand b { font-weight: 500; }
.brand-sub { font-size: 13px; color: var(--muted); margin-left: 6px; }

.main-nav { display: flex; gap: 18px; flex: 1; }
.nav-item {
    color: var(--muted);
    font-size: 14px;
    padding: 6px 4px;
    border-bottom: 2px solid transparent;
}
.nav-item:hover { color: var(--fg); text-decoration: none; }
.nav-item.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.topbar-actions { display: flex; align-items: center; gap: 12px; }
.balance-pill {
    background: var(--bg-alt);
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--fg);
}
.balance-pill .balance-num { font-weight: 600; color: var(--primary); }
.user-email { font-size: 13px; color: var(--muted); }

/* ===== buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 18px;
    border-radius: 18px;
    border: 0;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-ghost {
    background: transparent; color: var(--primary);
    border: 1px solid var(--line);
}
.btn-ghost:hover { background: #f1f8f5; border-color: #c7e7d8; text-decoration: none; }
.btn.danger { color: var(--danger); border-color: #f5cdc7; }
.btn.danger:hover { background: #fdebe8; }
.btn-primary.danger { background: var(--danger); color: #fff; border: 0; }

/* ===== layout ===== */
.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 28px 24px 60px;
}
.page-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
}
.page-title { font-size: 24px; font-weight: 500; margin-bottom: 16px; }
.page-footer {
    border-top: 1px solid var(--line);
    padding: 16px 24px;
    text-align: center;
    color: var(--muted);
}
.page-footer a { color: var(--muted); }

/* ===== cards ===== */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 28px; }
.card {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
}
.card-label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.card-value { font-size: 28px; font-weight: 500; }
.card-link { font-size: 13px; }

/* ===== blocks ===== */
.block { margin: 32px 0; }
.block-head {
    display: flex; justify-content: space-between; align-items: baseline;
    margin-bottom: 12px;
}
.block-head h2 { font-size: 18px; font-weight: 500; }
.more { font-size: 13px; }

/* ===== tables ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
    text-align: left;
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    font-size: 14px;
}
.data-table th { color: var(--muted); font-weight: 500; font-size: 12px; }
.data-table tr:hover td { background: #fafbfc; }
.data-table .truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plus { color: var(--plus); font-weight: 500; }
.minus { color: var(--minus); font-weight: 500; }
.empty { color: var(--muted); padding: 12px 0; }

/* ===== status pills ===== */
.status-active, .status-published { color: var(--primary); font-weight: 500; }
.status-suspended { color: var(--danger); }
.status-draft { color: var(--warn); }
.status-archived { color: var(--muted); }
.status-pending { color: var(--warn); }
.status-confirmed { color: var(--link); }
.status-credited { color: var(--primary); font-weight: 500; }
.status-failed { color: var(--danger); }

/* ===== forms ===== */
.form-narrow { max-width: 580px; }
.form-narrow label {
    display: block;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--muted);
}
.form-narrow input[type=email],
.form-narrow input[type=text],
.form-narrow input[type=password],
.form-narrow input[type=url],
.form-narrow select,
.form-narrow textarea {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 14px;
    color: var(--fg);
    background: var(--bg);
    margin-top: 4px;
}
.form-narrow input:focus, .form-narrow select:focus, .form-narrow textarea:focus {
    outline: 2px solid var(--primary);
    border-color: var(--primary);
}
.form-narrow textarea { resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 14px; }
.icon-fieldset {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 14px;
}
.icon-fieldset legend { padding: 0 6px; color: var(--muted); font-size: 13px; }

/* ===== auth shell ===== */
.auth-shell {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
    background: linear-gradient(120deg, #e3f2fd, #fce8e6);
}
.auth-card {
    background: var(--bg);
    border-radius: 16px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.08);
    padding: 32px;
    width: 100%;
    max-width: 420px;
}
.auth-card h1 { font-size: 22px; font-weight: 500; margin-bottom: 6px; }
.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.auth-card form label {
    display: block; margin-bottom: 12px; color: var(--muted); font-size: 13px;
}
.auth-card form input {
    display: block; width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 8px;
    font-size: 14px; margin-top: 4px;
}
.auth-card form .btn { width: 100%; margin-top: 10px; }
.auth-foot { margin-top: 16px; text-align: center; font-size: 13px; }

/* ===== messages ===== */
.error {
    background: #fdebe8;
    border: 1px solid #f5cdc7;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
}
.flash {
    background: #e6f4ea;
    border: 1px solid #cce8d3;
    color: var(--plus);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
}
.warn {
    background: #fef7e0;
    border: 1px solid #fde293;
    color: #5d4502;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
}

/* ===== app icons / lists ===== */
.app-mini-icon {
    display: inline-flex;
    width: 32px; height: 32px;
    border-radius: 8px;
    color: #fff; font-weight: 600; font-size: 12px;
    align-items: center; justify-content: center;
    margin-right: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.app-rows { list-style: none; }
.app-rows li {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--line);
}
.app-row-link { flex: 1; font-weight: 500; color: var(--fg); }
.app-row-link:hover { color: var(--link); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ===== packs ===== */
.pack-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px; margin: 18px 0;
}
.pack-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
}
.pack-card h3 { font-size: 16px; font-weight: 500; margin-bottom: 6px; }
.pack-price { font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.pack-sol {
    font-size: 30px; font-weight: 700; color: var(--fg);
    line-height: 1.15; margin: 8px 0 2px;
}
.pack-sol .unit { font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.pack-jpy-base { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.pack-credits { font-size: 14px; color: var(--primary); margin-bottom: 12px; }
.pack-card .btn { width: 100%; }
.price-note {
    background: var(--bg-alt);
    border-left: 3px solid var(--primary);
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 13px;
    color: var(--fg);
    margin: 12px 0 18px;
}

/* ===== misc ===== */
.big-balance { font-size: 40px; font-weight: 500; color: var(--primary); margin: 10px 0; }
.kv { margin: 10px 0; font-size: 14px; color: var(--muted); }
.kv .addr {
    display: block; padding: 8px 10px;
    background: var(--bg-alt); border-radius: 6px;
    color: var(--fg); word-break: break-all; margin-top: 4px;
}
.kv-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 16px 0 24px; font-size: 14px; }
.kv-list dt { color: var(--muted); }

/* ===== responsive ===== */
@media (max-width: 720px) {
    .topbar-inner { padding: 8px 12px; gap: 12px; flex-wrap: wrap; }
    .main-nav { order: 3; flex-basis: 100%; overflow-x: auto; }
    .user-email { display: none; }
    .page { padding: 18px 12px 60px; }
    .data-table th, .data-table td { padding: 8px 4px; font-size: 13px; }
    .data-table .truncate { max-width: 140px; }
}
