@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Noto+Sans+KR:wght@400;500;600;700&display=swap');

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

:root {
    --bg: #f5f6fa;
    --bg-card: #ffffff;
    --bg-input: #f0f1f5;
    --bg-section: #e8eaf0;
    --border: #e2e4ea;
    --text: #1a1d26;
    --text-dim: #6b7280;
    --text-muted: #9ca3af;
    --accent: #3b82f6;
    --accent-light: #eff6ff;
    --green: #16a34a;
    --green-bg: #f0fdf4;
    --green-light: rgba(22,163,74,.08);
    --red: #ef4444;
    --red-bg: #fef2f2;
    --red-light: rgba(239,68,68,.08);
    --orange: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-full: 9999px;
    --font: 'Noto Sans KR', -apple-system, sans-serif;
    --mono: 'JetBrains Mono', 'SF Mono', monospace;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.08);
    --transition: 200ms ease;
}

html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
    padding-bottom: 72px; /* 하단 네비 공간 */
}

/* ─── 하단 네비게이션 바 ─── */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    display: flex; justify-content: space-around;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 6px 0 env(safe-area-inset-bottom, 8px);
    box-shadow: 0 -2px 10px rgba(0,0,0,.05);
}
.nav-item {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    text-decoration: none; color: var(--text-muted);
    font-size: 10px; font-weight: 600;
    padding: 4px 16px; transition: color var(--transition);
}
.nav-item.active { color: var(--accent); }
.nav-item svg { transition: transform var(--transition); }
.nav-item.active svg { transform: scale(1.1); }

/* ─── 컨테이너 ─── */
.app-content { max-width: 480px; margin: 0 auto; min-height: 100vh; }

/* ─── 페이지 헤더 ─── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.page-header h1 { font-size: 17px; font-weight: 700; }
.page-header-back { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.page-header-actions { display: flex; gap: 8px; }

/* ─── 브랜드 로고 ─── */
.brand-logo {
    display: flex; align-items: center; gap: 8px;
}
.brand-logo svg { width: 32px; height: 32px; }
.brand-name {
    font-size: 17px; font-weight: 800; color: var(--text);
    letter-spacing: -0.5px;
}

/* ─── 섹션 ─── */
.section-wrap { padding: 16px 16px 8px; }
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px;
}
.section-header h3 { font-size: 15px; font-weight: 700; }

/* ─── 시세 티커 목록 ─── */
/* ─── 코인 선택 드롭다운 ─── */
.coin-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 60;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto;
}
.coin-dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; cursor: pointer; transition: background var(--transition);
}
.coin-dropdown-item:hover { background: var(--bg-input); }
.coin-dropdown-item .coin-dd-symbol { font-size: 13px; font-weight: 700; min-width: 50px; }
.coin-dropdown-item .coin-dd-name { font-size: 12px; color: var(--text-muted); }

.ticker-list { display: flex; flex-direction: column; gap: 4px; }
.ticker-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; background: var(--bg-card);
    border-radius: var(--radius); box-shadow: var(--shadow-sm);
    transition: all var(--transition); cursor: default;
    animation: fadeUp .3s ease-out both;
}
.ticker-row:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.ticker-left { display: flex; align-items: center; gap: 12px; }
.ticker-info { display: flex; flex-direction: column; }
.ticker-symbol { font-size: 14px; font-weight: 700; line-height: 1.2; }
.ticker-name { font-size: 11px; color: var(--text-muted); line-height: 1.2; margin-top: 2px; }
.ticker-right { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.ticker-price { font-family: var(--mono); font-size: 14px; font-weight: 700; }
.ticker-change {
    font-family: var(--mono); font-size: 11px; font-weight: 700;
    padding: 2px 6px; border-radius: 4px;
}
.ticker-skeleton {
    height: 60px; background: var(--bg-input); border-radius: var(--radius);
    animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
    0% { opacity: .6; } 50% { opacity: .3; } 100% { opacity: .6; }
}

/* ─── 탭 바 ─── */
.tab-bar {
    display: flex; background: var(--bg-card);
    border-bottom: 2px solid var(--border);
}
.tab-item {
    flex: 1; text-align: center; padding: 12px 0;
    font-size: 14px; font-weight: 600; color: var(--text-muted);
    text-decoration: none; border-bottom: 2px solid transparent;
    margin-bottom: -2px; transition: all var(--transition);
}
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ─── 버튼 ─── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 20px; border: none; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600; font-family: var(--font); text-decoration: none; transition: all var(--transition); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .9; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-secondary { background: var(--bg-input); color: var(--text-dim); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success { background: var(--green-bg); color: var(--green); }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn-full { width: 100%; padding: 14px; font-size: 15px; }
.btn-fab {
    position: fixed; bottom: 84px; right: max(20px, calc((100vw - 480px)/2 + 16px)); z-index: 90;
    width: 48px; height: 48px; border-radius: 14px;
    background: var(--accent); color: #fff; border: none;
    box-shadow: 0 4px 16px rgba(59,130,246,.4); cursor: pointer;
    font-size: 22px; font-weight: 300; display: flex; align-items: center; justify-content: center;
    transition: all var(--transition); text-decoration: none;
}
.btn-fab:hover { transform: scale(1.05) rotate(90deg); box-shadow: 0 6px 20px rgba(59,130,246,.5); }

/* ─── 카드 ─── */
.card {
    background: var(--bg-card); border-radius: var(--radius);
    box-shadow: var(--shadow-sm); margin: 12px 16px;
    overflow: hidden;
}
.card-inner { padding: 16px; }
.card-section { padding: 12px 16px; border-bottom: 1px solid var(--bg-section); }
.card-section:last-child { border-bottom: none; }

/* ─── 요약 카드 (대시보드 상단) ─── */
.summary-card {
    background: var(--bg-card); margin: 12px 16px; border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow-sm);
}
.summary-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.summary-item { display: flex; flex-direction: column; padding: 8px 0; }
.summary-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.summary-value { font-family: var(--mono); font-size: 16px; font-weight: 700; }
.summary-value.profit { color: var(--red); }
.summary-value.count { color: var(--text); }
.summary-value.amount { color: var(--accent); }

/* ─── 코인 가격 카드 ─── */
.price-card {
    background: var(--bg-card); margin: 0 16px 12px; border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow-sm);
}
.price-card-coin {
    display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.coin-icon {
    width: 36px; height: 36px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; font-weight: 700;
}
.coin-icon.btc { background: #fff3e0; color: #f59e0b; }
.coin-icon.eth { background: #ede9fe; color: #7c3aed; }
.coin-icon.xrp { background: #e0f2fe; color: #0284c7; }
.coin-name { font-size: 15px; font-weight: 700; }
.price-row { display: flex; justify-content: space-between; align-items: flex-end; }
.price-current { font-family: var(--mono); font-size: 26px; font-weight: 700; letter-spacing: -1px; }
.price-change { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.price-change.up { color: var(--red); }
.price-change.down { color: var(--accent); }
.price-meta { display: flex; justify-content: space-between; margin-top: 8px; }
.price-meta-item { font-size: 11px; color: var(--text-muted); }
.price-meta-item span { font-family: var(--mono); color: var(--red); font-weight: 600; }

/* ─── 입력 필드 ─── */
.input-field {
    width: 100%; padding: 12px 14px;
    background: var(--bg-input); border: 1px solid transparent;
    border-radius: var(--radius-sm); color: var(--text);
    font-size: 15px; font-family: var(--mono); outline: none;
    transition: all var(--transition);
}
.input-field:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.input-field::placeholder { color: var(--text-muted); font-family: var(--font); }
select.input-field {
    font-family: var(--font); cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px;
}

/* ─── 폼 ─── */
.form-group { margin-bottom: 12px; padding: 0 16px; }
.form-group.in-card { padding: 0; }
.form-label { display: block; margin-bottom: 5px; font-size: 12px; color: var(--text-muted); font-weight: 600; }
.form-hint { font-size: 10px; color: var(--accent); margin-bottom: 5px; }
.form-row { display: flex; gap: 10px; padding: 0 16px; margin-bottom: 12px; }
.form-half { flex: 1; }

/* 입력 + 모드 스위치 */
.input-with-mode { display: flex; align-items: center; gap: 8px; }
.input-with-mode .input-field { flex: 1; }
.mode-switch {
    position: relative; display: flex; align-items: center;
    background: var(--bg-input); border-radius: 20px;
    padding: 3px; flex-shrink: 0; cursor: pointer;
    border: 1px solid var(--border);
}
.mode-switch-slider {
    position: absolute; top: 3px; bottom: 3px;
    background: var(--accent); border-radius: 16px;
    transition: all 250ms cubic-bezier(.4,0,.2,1);
    box-shadow: 0 1px 3px rgba(59,130,246,.3);
}
.mode-option {
    position: relative; z-index: 1;
    padding: 6px 14px; font-size: 12px; font-weight: 700;
    color: var(--text-muted); cursor: pointer; border: none;
    background: transparent; font-family: var(--font);
    transition: color var(--transition); min-width: 36px; text-align: center;
}
.mode-option.active { color: #fff; }

/* ─── 토글 스위치 ─── */
.toggles-bar {
    display: flex; justify-content: space-around;
    padding: 12px 16px; gap: 4px;
}
.toggle-col {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 600; color: var(--text-dim);
}
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; inset: 0; background: #d1d5db;
    border-radius: 24px; cursor: pointer; transition: var(--transition);
}
.slider::before {
    content: ''; position: absolute;
    width: 18px; height: 18px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.toggle input:checked + .slider { background: var(--green); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* ─── 전략 카드 (목록) ─── */
.strategy-list { padding: 0 16px 16px; }
.strategy-card {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 16px; margin-bottom: 10px; box-shadow: var(--shadow-sm);
    transition: all var(--transition); position: relative; overflow: hidden;
}
.strategy-card:active { transform: scale(.98); }
.strategy-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.strategy-title { display: flex; align-items: center; gap: 8px; }
.strategy-exchange { font-size: 12px; font-weight: 700; color: var(--text-dim); }
.strategy-name { font-size: 12px; color: var(--text-muted); }
.strategy-card-coin { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.strategy-card-coin .coin-icon { width: 28px; height: 28px; font-size: 14px; }
.strategy-card-coin span { font-size: 14px; font-weight: 600; }
.strategy-card-stats { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.stat-item { text-align: center; }
.stat-label { font-size: 10px; color: var(--text-muted); }
.stat-value { font-family: var(--mono); font-size: 13px; font-weight: 600; }

/* 상태 배지 */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: var(--radius-full);
    font-size: 11px; font-weight: 700;
}
.badge-running { background: var(--green-bg); color: var(--green); }
.badge-running::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: blink 1.5s infinite; }
.badge-stopped { background: var(--bg-input); color: var(--text-muted); }
.badge-buy { background: var(--red-bg); color: var(--red); }
.badge-sell { background: var(--accent-light); color: var(--accent); }
.badge-done { background: var(--green-bg); color: var(--green); }
.badge-waiting { background: var(--bg-input); color: var(--text-muted); }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ─── 거래현황 상세 - 차수별 카드 ─── */
.position-card {
    background: var(--bg-card); border-radius: var(--radius);
    margin: 10px 16px; padding: 16px; box-shadow: var(--shadow-sm);
}
.position-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.position-level { font-size: 13px; font-weight: 700; padding: 4px 12px; background: var(--bg-input); border-radius: var(--radius-full); }
.position-date { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.position-row { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; }
.position-row .label { color: var(--text-muted); }
.position-row .value { font-family: var(--mono); font-weight: 500; }
.position-row .value.target { color: var(--accent); }
.position-profit { display: flex; justify-content: space-between; padding: 8px 0 0; margin-top: 8px; border-top: 1px solid var(--bg-section); font-size: 13px; font-weight: 600; }
.position-toggles { display: flex; gap: 20px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--bg-section); }
.position-toggle-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); }

/* 매수/매도 2열 레이아웃 */
.position-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.position-grid-header { font-size: 11px; color: var(--text-muted); font-weight: 600; text-align: center; padding: 6px 0; }
.position-grid-row { display: contents; }
.position-grid-label { font-size: 12px; color: var(--text-muted); padding: 4px 0; grid-column: 1 / -1; }

/* ─── 투자내역 (실현손익) ─── */
.history-card {
    background: var(--bg-card); border-radius: var(--radius);
    margin: 10px 16px; padding: 16px; box-shadow: var(--shadow-sm);
}
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.history-exchange { font-size: 14px; font-weight: 700; }
.history-date { font-size: 11px; color: var(--text-muted); }
.history-coin { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.history-detail { display: grid; grid-template-columns: auto 1fr 1fr; gap: 4px 16px; font-size: 12px; }
.history-detail .label { color: var(--text-muted); }
.history-detail .value { font-family: var(--mono); text-align: right; }
.history-profit {
    text-align: right; font-family: var(--mono); font-size: 16px;
    font-weight: 700; margin-top: 10px; padding-top: 10px;
    border-top: 1px solid var(--bg-section);
}

/* ─── 설정 페이지 ─── */
.settings-section { padding: 16px; }
.settings-section h3 { font-size: 15px; margin-bottom: 4px; }
.settings-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; line-height: 1.6; }
.exchange-card {
    background: var(--bg-card); border-radius: var(--radius);
    padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm);
}
.exchange-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.exchange-card-header h4 { font-size: 15px; font-weight: 700; }
.key-badge { font-size: 10px; padding: 3px 10px; border-radius: var(--radius-full); font-weight: 700; }
.key-badge.registered { background: var(--green-bg); color: var(--green); }
.key-badge.unregistered { background: var(--bg-input); color: var(--text-muted); }
.exchange-card .input-field { margin-bottom: 8px; }
.exchange-card .btn-row { display: flex; gap: 8px; }

/* ─── 그리드 미리보기 ─── */
.grid-preview { margin: 16px; }
.grid-preview h3 { font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 8px; }
.grid-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    font-size: 12px; border-radius: var(--radius-sm); overflow: hidden;
    background: var(--bg-card); box-shadow: var(--shadow-sm);
}
.grid-table th {
    background: var(--bg-input); padding: 8px 12px;
    text-align: center; font-weight: 600; color: var(--text-muted); font-size: 11px;
}
.grid-table td {
    padding: 8px 12px; text-align: center;
    font-family: var(--mono); font-size: 12px;
    border-top: 1px solid var(--bg-section);
}

/* ─── 수익 색상 ─── */
.profit-plus { color: var(--red); font-weight: 700; }
.profit-minus { color: var(--accent); font-weight: 700; }

/* ─── 빈 상태 ─── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state p { margin-bottom: 16px; font-size: 14px; }

/* ─── 로그인 ─── */
.login-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; background: #fff;
    padding-bottom: 0;
}
.login-body .bottom-nav { display: none; }
.login-container {
    width: 100%; max-width: 380px; padding: 40px 24px;
}
.login-logo {
    display: flex; justify-content: center; margin-bottom: 16px;
}
.login-logo svg { width: 56px; height: 56px; }
.login-container h1 {
    font-size: 22px; font-weight: 800;
    color: var(--text); text-align: center; margin-bottom: 4px;
    letter-spacing: -0.5px;
}
.login-subtitle { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 32px; }
.login-container .input-field { margin-bottom: 10px; font-family: var(--font); }
.login-container .btn { width: 100%; margin-bottom: 8px; }
.error-msg {
    background: var(--red-bg); color: var(--red); padding: 10px 14px;
    border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 14px; text-align: center;
}

/* ─── 위험 구역 ─── */
.danger-zone { margin: 32px 16px 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ─── 날짜 필터 바 ─── */
.date-filter {
    display: flex; align-items: center; gap: 8px;
    padding: 12px 16px; background: var(--bg-card);
    margin: 12px 16px; border-radius: var(--radius);
    box-shadow: var(--shadow-sm); flex-wrap: wrap;
}
.date-input {
    padding: 6px 10px; font-size: 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); background: var(--bg-input);
    font-family: var(--font); color: var(--text);
}
.filter-chip {
    padding: 6px 14px; font-size: 12px; font-weight: 600;
    border: 1px solid var(--border); border-radius: var(--radius-full);
    background: var(--bg-card); color: var(--text-dim); cursor: pointer;
}
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ─── 모달 ─── */
.modal {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: flex-end; justify-content: center;
    background: rgba(0,0,0,.4);
    animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
    background: var(--bg-card); border-radius: 20px 20px 0 0;
    padding: 24px 20px 32px; width: 100%; max-width: 480px;
    animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; }
.modal-stat { padding: 10px 12px; background: var(--bg-input); border-radius: var(--radius-sm); }
.modal-stat-label { font-size: 10px; color: var(--text-muted); margin-bottom: 2px; }
.modal-stat-value { font-family: var(--mono); font-size: 13px; font-weight: 600; }

/* ─── 스크롤바 ─── */
::-webkit-scrollbar { width: 0; height: 0; }

/* ─── 반응형 ─── */
@media (min-width: 481px) {
    .app-content { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
    .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); }
}

/* ─── 애니메이션 ─── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.card, .strategy-card, .position-card, .history-card, .summary-card, .exchange-card {
    animation: fadeUp .25s ease-out both;
}
