:root {
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e3e8ef;
    --text: #1e2530;
    --text-muted: #6b7684;
    --primary: #3182f6;      /* 토스 블루 계열 */
    --primary-dark: #1b64da;
    --primary-soft: #e8f1ff;
    --up: #f04452;           /* 상승/매수 강조 (한국식: 빨강=상승) */
    --up-soft: #fdeded;
    --down: #3182f6;         /* 하락/매도 (파랑) */
    --down-soft: #e8f1ff;
    --success: #14ae5c;
    --warn: #ff9800;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "맑은 고딕", Roboto, "Apple SD Gothic Neo", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

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

.container { max-width: 1140px; margin: 0 auto; padding: 0 20px; }

/* ── Topbar ── */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 62px; }
.brand { font-size: 20px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.brand:hover { text-decoration: none; }
.brand-mark { margin-right: 4px; }
.brand-accent { color: var(--primary); }
.nav { display: flex; align-items: center; gap: 4px; flex: 1; }
.nav-link {
    color: var(--text-muted); font-weight: 600; padding: 8px 14px; border-radius: 8px;
    font-size: 14.5px;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.nav-link.active { color: var(--primary); background: var(--primary-soft); }
.user-area { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--text-muted); font-size: 14px; font-weight: 600; }
.inline-form { display: inline; margin: 0; }

/* ── Main / Footer ── */
.main { padding: 28px 20px 60px; min-height: calc(100vh - 62px - 60px); }
.footer {
    border-top: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); font-size: 13px;
}
.footer-inner { display: flex; justify-content: space-between; align-items: center; height: 60px; gap: 16px; flex-wrap: wrap; }
.footer-warn { color: var(--warn); font-weight: 600; }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent; border-radius: 10px; padding: 11px 18px;
    font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn-sm { padding: 7px 13px; font-size: 13.5px; border-radius: 8px; }
.btn-lg { padding: 14px 22px; font-size: 16px; width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: #fff; color: var(--up); border-color: #f3c0c4; }
.btn-danger:hover { background: var(--up-soft); }
.btn-buy { background: var(--up); color: #fff; }
.btn-buy:hover { background: #d63a47; color:#fff; }
.btn-sell { background: var(--down); color: #fff; }
.btn-sell:hover { background: var(--primary-dark); color:#fff; }

/* ── Cards ── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.card + .card { margin-top: 18px; }
.card-title { font-size: 16px; font-weight: 800; margin: 0 0 16px; letter-spacing: -0.3px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header .card-title { margin: 0; }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 24px; font-weight: 800; margin: 0; letter-spacing: -0.6px; }
.page-sub { color: var(--text-muted); font-size: 14px; margin: 4px 0 0; }

/* ── Stat grid ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; box-shadow: var(--shadow);
}
.stat-label { color: var(--text-muted); font-size: 13.5px; font-weight: 600; margin-bottom: 8px; }
.stat-value { font-size: 24px; font-weight: 800; letter-spacing: -0.5px; }
.stat-sub { font-size: 13px; margin-top: 6px; font-weight: 600; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--text-muted); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 13px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th { color: var(--text-muted); font-weight: 700; font-size: 12.5px; background: var(--surface-2); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Badges ── */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-on { background: #e6f7ee; color: var(--success); }
.badge-off { background: #eef1f5; color: var(--text-muted); }
.badge-buy { background: var(--up-soft); color: var(--up); }
.badge-sell { background: var(--down-soft); color: var(--down); }
.badge-live { background: #fff3e0; color: var(--warn); }
.badge-sim { background: #eef1f5; color: var(--text-muted); }
.badge-success { background: #e6f7ee; color: var(--success); }
.badge-failed { background: var(--up-soft); color: var(--up); }

/* ── Forms ── */
.form { max-width: 480px; }
.form-wide { max-width: 640px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 7px; }
.form-control {
    width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
    font-size: 15px; font-family: inherit; background: #fff; color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(49,130,246,.15); }
.form-hint { color: var(--text-muted); font-size: 12.5px; margin-top: 6px; }
.field-validation-error, .validation-summary-errors { color: var(--up); font-size: 13px; font-weight: 600; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.input-error { border-color: var(--up); }
.checkbox-row { display: flex; align-items: center; gap: 9px; }
.checkbox-row input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); }
.checkbox-row label { margin: 0; font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }

/* ── Auth cards ── */
.auth-wrap { max-width: 420px; margin: 40px auto; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 34px 30px; }
.auth-title { font-size: 22px; font-weight: 800; margin: 0 0 6px; }
.auth-sub { color: var(--text-muted); font-size: 14px; margin: 0 0 24px; }
.auth-foot { text-align: center; margin-top: 18px; color: var(--text-muted); font-size: 14px; }

/* ── Toast ── */
.toast { padding: 13px 18px; border-radius: 10px; font-weight: 600; margin-bottom: 18px; font-size: 14px; }
.toast-success { background: #e6f7ee; color: #0f7a41; border: 1px solid #b6e6ca; }
.toast-error { background: var(--up-soft); color: #b3242f; border: 1px solid #f3c0c4; }

/* ── Alert ── */
.alert { padding: 14px 18px; border-radius: 10px; font-size: 14px; margin-bottom: 18px; }
.alert-warn { background: #fff8e6; color: #9a6700; border: 1px solid #ffe08a; }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #c6dcff; }

/* ── Landing hero ── */
.hero { text-align: center; padding: 70px 20px 40px; }
.hero h1 { font-size: 42px; font-weight: 800; letter-spacing: -1.2px; margin: 0 0 14px; }
.hero p { font-size: 18px; color: var(--text-muted); max-width: 620px; margin: 0 auto 30px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; margin-top: 50px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; box-shadow: var(--shadow); text-align: left; }
.feature .ico { font-size: 30px; }
.feature h3 { margin: 12px 0 8px; font-size: 17px; }
.feature p { font-size: 14px; color: var(--text-muted); margin: 0; }

.empty { text-align: center; color: var(--text-muted); padding: 46px 20px; }
.empty .ico { font-size: 40px; }
.empty p { margin: 12px 0 20px; }

.mono { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.mt-0 { margin-top: 0; }
.actions-cell { display: flex; gap: 6px; }

/* ── Settings ── */
.setting-item {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 20px;
    padding: 18px 0; border-bottom: 1px solid var(--border);
}
.setting-item:last-of-type { border-bottom: none; }
.setting-text { flex: 1; }
.setting-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.setting-desc { color: var(--text-muted); font-size: 13px; margin-top: 5px; line-height: 1.5; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 50px; height: 28px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0; background: #cfd6df;
    transition: .2s; border-radius: 999px;
}
.slider:before {
    content: ""; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px;
    background: #fff; transition: .2s; border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(22px); }
.switch input:focus + .slider { box-shadow: 0 0 0 3px rgba(49,130,246,.2); }

@media (max-width: 760px) {
    .topbar-inner { gap: 12px; }
    .nav { gap: 0; flex-wrap: wrap; }
    .nav-link { padding: 6px 9px; font-size: 13px; }
    .user-name { display: none; }
    .form-row { grid-template-columns: 1fr; }
    .hero h1 { font-size: 30px; }
}
