:root {
    --bg: #0b0b0b;
    --text: #eaeaea;
    --text-sub: #9a9a9a;
    --card: #1b1b1b;
    --border: #2a2a2a;
    --input-bg: #222;
    --input-border: #333;
    --shadow: rgba(0, 0, 0, 0.5);
    --accent: #4da3ff;
    --accent-hover: #1a73e8;
    --green: #4cd964;
    --red: #ff5252;
    --hover-bg: #202020;
    --overlay: rgba(0, 0, 0, 0.6);
    --radius: 16px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
}

.alert {
    padding: 16px;
    margin: 16px auto;
    max-width: 520px;
    border-radius: 12px;
    text-align: center;
}

.alert-success {
    color: var(--green);
    border: 1px solid var(--green);
}

.alert-error {
    color: var(--red);
    border: 1px solid var(--red);
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px var(--shadow);
}

/* header */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}

.header-actions {
    display: flex;
    gap: 12px;
}

.header-bar .title {
    font-weight: 700;
    font-size: 16px;
    text-align: center;
    flex: 1;
}

/* icon btn */
.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
}

/* summary */
.summary-card {
    text-align: center;
    margin-bottom: 20px;
}

.summary-label {
    font-size: 12px;
    color: var(--text-sub);
}

.summary-amount {
    font-size: 46px;
    font-weight: 700;
    margin: 12px 0;
}

.pnl-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.pnl-badge {
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
}

.badge-positive {
    background: var(--red);
}

.badge-negative {
    background: var(--green);
}

.badge-zero {
    background: #6c757d;
}

/* chart */
.chart-section {
    margin-bottom: 20px;
}

.tab-nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 10px;
    color: var(--text-sub);
    background: none;
    border: none;
}

.tab-btn.active {
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
}

.tab-panels {
    padding: 16px;
}

/* asset grid */
.asset-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.asset-tile {
    padding: 14px;
}

.tile-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tile-icon {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--hover-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tile-amount {
    font-size: 16px;
    font-weight: 700;
}

/* manage page */
.manage-header {
    text-align: center;
    margin-bottom: 20px;
}

.manage-title {
    font-size: 13px;
    color: var(--text-sub);
    margin-bottom: 6px;
}

.manage-total {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 10px;
}

.manage-pnl {
    font-size: 14px;
    font-weight: 700;
}

.asset-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.asset-item .top-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.asset-name {
    font-size: 16px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.asset-name small {
    font-size: 12px;
    color: var(--text-sub);
}

.action-btns {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--hover-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.action-btn.danger {
    color: var(--red);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
}

.detail-cell {
    background: var(--hover-bg);
    padding: 10px;
    border-radius: 10px;
}

.detail-cell.span2 {
    grid-column: span 2;
}

.detail-cell .dt {
    font-size: 11px;
    color: var(--text-sub);
}

.detail-cell .dd {
    font-size: 13px;
    font-weight: 700;
}

.detail-cell .dd.lg {
    font-size: 15px;
}

.loan-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.loan-col {
    background: var(--hover-bg);
    padding: 10px;
    border-radius: 10px;
    text-align: center;
}

.loan-label {
    font-size: 11px;
    color: var(--text-sub);
}

.loan-val {
    font-weight: 700;
}

.fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    border: none;
    box-shadow: 0 6px 18px rgba(77, 163, 255, 0.4);
}

/* modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    width: 100%;
    max-width: 420px;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 16px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    font-size: 12px;
    color: var(--text-sub);
    display: block;
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--input-bg);
    color: var(--text);
}

.btn-primary {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    font-weight: 700;
}

.search-wrap {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 6px;
    max-height: 220px;
    overflow-y: auto;
    display: none;
}

.search-results.open {
    display: block;
}

.search-item {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}

.search-item:hover {
    background: var(--hover-bg);
}

.search-item-symbol {
    font-weight: 700;
    margin-right: 6px;
}

.search-item-name {
    font-size: 12px;
    color: var(--text-sub);
}

.custom-input {
    display: none;
}

.memo-box {
    margin-top: 10px;
    padding: 8px 10px;
    background: var(--hover-bg);
    border-radius: 8px;
    font-size: 12px;
    color: var(--text-sub);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-sub);
}

.empty-icon {
    font-size: 56px;
    opacity: 0.3;
}

/* auth */
.auth-body {
    background: var(--bg);
}

.auth-bg {
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-card {
    background: var(--card);
    border-radius: 16px;
    border: 1px solid var(--border);
    padding: 32px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.auth-logo {
    width: 52px;
    height: 52px;
    margin: 0 auto 12px auto;
    background: #202020;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.auth-subtitle {
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 18px;
}

.auth-form {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.field-label {
    font-size: 12px;
    color: var(--text-sub);
    margin-bottom: 6px;
    display: block;
}

.field-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text);
}

.auth-submit {
    padding: 12px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.auth-switch {
    margin-top: 14px;
    font-size: 12px;
    color: var(--text-sub);
}

.toast {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e1e1e;
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    z-index: 9999;
    font-size: 12px;
}

.toast-success {
    border: 1px solid var(--green);
}

.toast-error {
    border: 1px solid var(--red);
}