/* ============================================================
   FarmBot v3 — Clean Dashboard (Rose/Pink)
   Notion-inspired · Light sidebar · Full responsive
   ============================================================ */

/* --- 라이트 테마 --- */
:root {
    --bg: #f8f8fa;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-sidebar-hover: #fdf2f8;
    --bg-sidebar-active: #fce7f3;
    --text: #18181b;
    --text-muted: #71717a;
    --text-sidebar: #52525b;
    --text-sidebar-active: #be185d;
    --border: #f0f0f3;
    --border-strong: #e4e4e7;
    --primary: #ec4899;
    --primary-hover: #db2777;
    --primary-subtle: rgba(236,72,153,.06);
    --success: #22c55e;
    --success-subtle: rgba(34,197,94,.08);
    --danger: #ef4444;
    --danger-subtle: rgba(239,68,68,.08);
    --warning: #f59e0b;
    --warning-subtle: rgba(245,158,11,.08);
    --info: #ec4899;
    --shadow-xs: 0 1px 2px rgba(0,0,0,.03);
    --shadow: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.02);
    --shadow-md: 0 4px 12px rgba(0,0,0,.05);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.07);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-w: 232px;
    --topbar-h: 52px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* --- 다크 테마 --- */
.dark {
    --bg: #09090b;
    --bg-card: #18181b;
    --bg-sidebar: #111113;
    --bg-sidebar-hover: rgba(236,72,153,.06);
    --bg-sidebar-active: rgba(236,72,153,.1);
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-sidebar: #a1a1aa;
    --text-sidebar-active: #f9a8d4;
    --border: #27272a;
    --border-strong: #3f3f46;
    --shadow-xs: 0 1px 2px rgba(0,0,0,.2);
    --shadow: 0 1px 3px rgba(0,0,0,.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,.5);
}

/* --- 리셋 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }

/* ============================================================
   레이아웃
   ============================================================ */
.app { display: flex; min-height: 100vh; }

/* --- 사이드바 (Notion 스타일 — 라이트) --- */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 1000;
    transition: transform .25s cubic-bezier(.4,0,.2,1);
}
.sidebar-brand {
    padding: 20px 16px 16px;
    font-size: .95rem; font-weight: 700;
    color: var(--text);
    display: flex; align-items: center; gap: 8px;
}
.sidebar-brand i { color: var(--primary); font-size: 1.1rem; }

.sidebar-user {
    padding: 0 12px 14px;
    display: flex; align-items: center; gap: 8px;
}
.sidebar-user-avatar {
    width: 28px; height: 28px;
    background: linear-gradient(135deg, #ec4899, #f9a8d4);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: .7rem; font-weight: 600;
}
.sidebar-user-name { color: var(--text-muted); font-size: .82rem; font-weight: 500; }

.sidebar-nav {
    flex: 1; padding: 4px 8px; overflow-y: auto;
    border-top: 1px solid var(--border);
}
.sidebar-link {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text-sidebar);
    font-size: .85rem; font-weight: 500;
    transition: all .1s;
    margin-bottom: 1px;
}
.sidebar-link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text);
}
.sidebar-link.active {
    background: var(--bg-sidebar-active);
    color: var(--text-sidebar-active);
    font-weight: 600;
}
.sidebar-link i { width: 18px; text-align: center; font-size: .85rem; }

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.dark-toggle {
    background: none; border: none; color: var(--text-muted);
    font-size: .95rem; cursor: pointer; padding: 6px 8px;
    border-radius: 6px; transition: all .1s;
}
.dark-toggle:hover { background: var(--primary-subtle); color: var(--primary); }

/* --- 메인 영역 --- */
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }

.topbar {
    display: none;
    position: sticky; top: 0; z-index: 500;
    height: var(--topbar-h);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    align-items: center; gap: 10px;
}
.topbar-menu { display: none; background: none; border: none; font-size: 1.15rem; color: var(--text); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.topbar-menu:hover { background: var(--primary-subtle); }
.topbar-title { flex: 1; font-size: .95rem; font-weight: 600; }
.mobile-dark { background: none; border: none; font-size: .95rem; color: var(--text-muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; }

.main-content { padding: 24px; max-width: 1400px; }

/* ============================================================
   카드
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    box-shadow: var(--shadow-xs);
}
.card-header {
    padding: 13px 18px;
    font-weight: 600; font-size: .9rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    color: var(--text);
}
.card-body { padding: 16px 18px; }

/* --- 통계 카드 --- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 18px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); letter-spacing: -.02em; }
.stat-card .stat-label { font-size: .78rem; color: var(--text-muted); margin-top: 2px; font-weight: 500; }

/* --- 자원 카드 --- */
.resource-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px; margin: 12px 0;
}
.resource-card {
    border-radius: var(--radius-lg); padding: 16px 12px;
    text-align: center; color: #fff;
    transition: transform .12s, box-shadow .12s;
}
.resource-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.resource-card i { font-size: 1.2rem; display: block; margin-bottom: 4px; opacity: .85; }
.resource-card .label { display: block; font-size: .72rem; font-weight: 500; opacity: .85; margin-bottom: 2px; }
.resource-card .value { font-size: 1.1rem; font-weight: 700; }

.resource-card.tomato { background: linear-gradient(135deg, #e11d48, #fb7185); }
.resource-card.wood   { background: linear-gradient(135deg, #16a34a, #4ade80); }
.resource-card.iron   { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.resource-card.oil    { background: linear-gradient(135deg, #525252, #a1a1aa); }
.resource-card.total  { background: linear-gradient(135deg, #be185d, #f472b6); }

.resource-grid.compact { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.resource-card.small { padding: 10px 8px; }
.resource-card.small i { font-size: 1rem; margin-bottom: 2px; }
.resource-card.small .label { font-size: .68rem; }
.resource-card.small .value { font-size: .9rem; }

/* --- 탭 --- */
.tab-nav {
    display: flex; flex-wrap: wrap; gap: 2px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.tab-button {
    background: transparent; border: none;
    padding: 8px 14px;
    cursor: pointer; font-weight: 500; font-size: .85rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all .1s;
    border-radius: 0;
}
.tab-button:hover { color: var(--primary); }
.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn .2s ease; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .2s ease; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- 동맹/유저 --- */
.ally-summary {
    background: var(--bg); border-radius: var(--radius);
    padding: 14px; margin-bottom: 12px;
    border-left: 3px solid var(--primary);
}
.ally-summary h4 { margin-bottom: 8px; font-size: .92rem; }

.user-list { margin-top: 10px; }
.user-row {
    background: var(--bg); border-radius: var(--radius);
    padding: 10px 14px; margin-bottom: 4px;
    border-left: 3px solid var(--primary);
    transition: background .1s;
}
.user-row:hover { background: var(--primary-subtle); }
.user-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.user-info strong { font-size: .88rem; }
.user-total { font-weight: 600; color: var(--primary); font-size: .88rem; }
.user-resources { display: flex; flex-wrap: wrap; gap: 4px; }
.resource-item {
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 2px 8px; border-radius: 4px;
    font-size: .78rem; font-weight: 500;
    display: flex; align-items: center; gap: 3px;
}
.resource-item.tomato { border-left: 2px solid #e11d48; }
.resource-item.wood   { border-left: 2px solid #16a34a; }
.resource-item.iron   { border-left: 2px solid #7c3aed; }
.resource-item.oil    { border-left: 2px solid #71717a; }

/* --- 원화 환산 --- */
.krw-total-card {
    background: linear-gradient(135deg, #ec4899, #f9a8d4);
    color: #fff; border-radius: var(--radius-lg);
    padding: 18px; text-align: center; margin-bottom: 14px;
}
.krw-total-card i { font-size: 1.4rem; display: block; margin-bottom: 4px; }
.krw-total-card .krw-label { font-weight: 500; font-size: .82rem; opacity: .9; }
.krw-total-card .krw-value { font-size: 1.5rem; font-weight: 700; }
.dark.krw-total-card { background: linear-gradient(135deg, #9d174d, #ec4899); }

.krw-ally-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.krw-ally-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; border-left: 3px solid var(--primary); }
.krw-ally-name { font-weight: 600; margin-bottom: 2px; font-size: .88rem; }
.krw-ally-value { font-size: 1.1rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.krw-ally-detail { display: flex; flex-wrap: wrap; gap: 6px; font-size: .73rem; color: var(--text-muted); }
.krw-ally-detail span { display: inline-flex; align-items: center; gap: 2px; }
.krw-rate-info { color: var(--text-muted); font-size: .78rem; margin-bottom: 10px; }
.section-header-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

/* ============================================================
   테이블
   ============================================================ */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; font-size: .84rem; }
th {
    font-weight: 600; color: var(--text-muted);
    font-size: .72rem; text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 1px solid var(--border-strong);
    white-space: nowrap; background: var(--bg-card);
    position: sticky; top: 0; z-index: 1;
}
td { border-bottom: 1px solid var(--border); }
tbody tr { transition: background .08s; }
tbody tr:hover { background: var(--primary-subtle); }

.accounts-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.accounts-table th {
    padding: 8px; font-weight: 600; color: var(--text-muted);
    font-size: .7rem; text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 1px solid var(--border-strong); white-space: nowrap;
    background: var(--bg-card);
}
.accounts-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.accounts-table tbody tr { transition: background .08s; }
.accounts-table tbody tr:hover { background: var(--primary-subtle); }
.accounts-table tr.dragging { opacity: .3; }
.accounts-table tr[data-hidden="true"] { display: none; }

.krw-table th, .krw-table td { text-align: right; white-space: nowrap; padding: 8px 10px; }
.krw-table th:first-child, .krw-table td:first-child,
.krw-table th:nth-child(2), .krw-table td:nth-child(2) { text-align: left; }
.sortable { cursor: pointer; -webkit-user-select: none; user-select: none; }
.sortable:hover { color: var(--primary); }
.sort-icon { font-size: .6rem; margin-left: 3px; opacity: .3; }
.sortable[data-dir] .sort-icon { opacity: 1; color: var(--primary); }
.krw-cell { color: var(--primary); font-weight: 600; }
.krw-footer-row { background: var(--bg); font-weight: 600; }
.krw-footer-row td { border-top: 2px solid var(--border-strong); }
.krw-table-wrapper { overflow-x: auto; }

/* ============================================================
   폼
   ============================================================ */
.form-row { display: flex; gap: 10px; margin-bottom: 10px; align-items: end; }
.form-group { flex: 1; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 600; font-size: .78rem; color: var(--text-muted); }
.form-control {
    width: 100%; padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 6px; font-size: .85rem;
    background: var(--bg-card); color: var(--text);
    transition: border-color .12s, box-shadow .12s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(236,72,153,.1); }
select.form-control { appearance: auto; }

/* ============================================================
   버튼
   ============================================================ */
.btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 7px 14px; border: none; border-radius: 6px;
    font-size: .84rem; font-weight: 600;
    cursor: pointer; transition: all .12s;
    text-decoration: none; line-height: 1.4;
    white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; box-shadow: 0 2px 8px rgba(236,72,153,.25); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--bg); border-color: var(--text-muted); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-xs { padding: 3px 8px; font-size: .75rem; border-radius: 5px; }
.btn-csv { background: var(--success); color: #fff; }

/* ============================================================
   배지
   ============================================================ */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px; height: 20px;
    border-radius: 4px; font-size: .72rem; font-weight: 600;
}
.badge-blue { background: rgba(236,72,153,.08); color: var(--primary); }
.badge-green { background: var(--success-subtle); color: var(--success); }
.badge-red { background: var(--danger-subtle); color: var(--danger); }
.badge-gray { background: rgba(113,113,122,.08); color: var(--text-muted); }
.badge-yellow { background: var(--warning-subtle); color: #92400e; }

/* ============================================================
   알림
   ============================================================ */
.alert {
    padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px;
    font-size: .84rem; border-left: 3px solid;
}
.alert-success { background: var(--success-subtle); color: #166534; border-color: var(--success); }
.alert-error, .alert-danger { background: var(--danger-subtle); color: #991b1b; border-color: var(--danger); }
.dark.alert-success { color: #86efac; }
.dark.alert-error, .dark.alert-danger { color: #fca5a5; }

/* ============================================================
   토글 스위치
   ============================================================ */
.toggle-switch { position: relative; display: inline-block; width: 38px; height: 20px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--border-strong); transition: .2s; border-radius: 20px;
}
.slider::before {
    content: ""; position: absolute;
    height: 14px; width: 14px; left: 3px; bottom: 3px;
    background: #fff; transition: .2s; border-radius: 50%;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
input:checked + .slider { background: var(--primary); }
input:checked + .slider::before { transform: translateX(18px); }

/* 작은 토글 (계정 목록용) */
.toggle-sm { position: relative; display: inline-block; width: 32px; height: 16px; }
.toggle-sm input { opacity: 0; width: 0; height: 0; }
.toggle-sm .slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--border-strong); border-radius: 16px; transition: .15s;
}
.toggle-sm .slider::before {
    content: ""; position: absolute;
    height: 12px; width: 12px; left: 2px; bottom: 2px;
    background: #fff; border-radius: 50%; transition: .15s;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
}
.toggle-sm input:checked + .slider { background: var(--primary); }
.toggle-sm input:checked + .slider::before { transform: translateX(16px); }

/* ============================================================
   모달
   ============================================================ */
.modal-overlay, .modal-bg {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.4); z-index: 2000;
    align-items: center; justify-content: center;
    -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.modal-overlay.active, .modal-bg.active { display: flex; }
.modal {
    background: var(--bg-card); border-radius: var(--radius-lg);
    padding: 24px; width: 460px; max-width: 94vw;
    box-shadow: var(--shadow-lg); border: 1px solid var(--border);
    max-height: 90vh; overflow-y: auto;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: .95rem; font-weight: 600; margin: 0; }
.modal-close {
    background: none; border: none; font-size: 1.3rem;
    color: var(--text-muted); cursor: pointer; padding: 2px 6px;
    border-radius: 4px; line-height: 1;
}
.modal-close:hover { background: var(--danger-subtle); color: var(--danger); }
.modal-body { font-size: .88rem; }
.modal-title { font-size: 1rem; font-weight: 600; margin-bottom: 14px; }

/* ============================================================
   Accounts 전용 요소
   ============================================================ */
.acc-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 24px; height: 24px; padding: 0 6px;
    border-radius: 6px;
    background: var(--primary); color: #fff;
    font-weight: 700; font-size: .72rem;
}
.grp-badge {
    display: inline-block; padding: 1px 7px;
    border-radius: 4px; font-size: .72rem; font-weight: 600;
    background: var(--primary-subtle); color: var(--primary);
}
.grp-badge.none { background: var(--bg); color: var(--text-muted); }

.res-select {
    width: 38px; padding: 2px 1px;
    border: 1px solid var(--border-strong);
    border-radius: 4px; font-size: .78rem; text-align: center;
    background: var(--bg-card); color: var(--text);
}
.res-total { font-weight: 700; font-size: .78rem; }
.res-total.over { color: var(--danger); }
.res-total.ok { color: var(--success); }

.group-select {
    padding: 5px 8px; border: 1px solid var(--border-strong);
    border-radius: 5px; font-size: .82rem;
    background: var(--bg-card); color: var(--text);
}

/* ============================================================
   기타 컴포넌트
   ============================================================ */
.loading {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid var(--border); border-top-color: var(--primary);
    border-radius: 50%; animation: spin .5s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; flex-wrap: wrap; gap: 8px; }
.page-title { font-size: 1.2rem; font-weight: 700; }

#status-container p, #log-container p {
    background: var(--bg); padding: 8px 12px;
    border-radius: 5px; margin-bottom: 4px; font-size: .84rem;
}
#log-container { max-height: 260px; overflow-y: auto; }

/* 유틸 */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.hidden { display: none; }
.flex { display: flex; }
.flex-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.actions { display: flex; gap: 6px; }

/* ============================================================
   홈페이지 (비로그인)
   ============================================================ */
.hero {
    background: linear-gradient(135deg, #be185d 0%, #ec4899 50%, #f9a8d4 100%);
    color: #fff; padding: 60px 0; text-align: center;
}
.hero h1 { font-size: 2.2rem; font-weight: 700; margin-bottom: 12px; }
.hero p { font-size: 1.05rem; opacity: .92; margin-bottom: 24px; }
.hero .btn { font-size: .92rem; padding: 11px 22px; margin: 0 4px; }

.header { background: linear-gradient(135deg, #be185d, #ec4899); color: #fff; padding: .7rem 0; }
.header .container { max-width: 1200px; margin: 0 auto; padding: 0 16px; display: flex; justify-content: space-between; align-items: center; }
.header h1 { font-size: 1.3rem; font-weight: 600; }
.header .nav a { color: #fff; margin-left: 10px; padding: 6px 12px; border-radius: 6px; transition: background .12s; }
.header .nav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.container-page { max-width: 1200px; margin: 0 auto; padding: 16px; }
.features { padding: 48px 0; background: var(--bg); }
.features-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-top: 28px; }
.feature-card { background: var(--bg-card); padding: 28px; border-radius: var(--radius-lg); box-shadow: var(--shadow); text-align: center; border: 1px solid var(--border); transition: transform .15s; }
.feature-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.feature-icon { font-size: 1.8rem; margin-bottom: 10px; color: var(--primary); }
.feature-card h3 { color: var(--text); margin-bottom: 6px; font-size: 1rem; }
.stats { background: linear-gradient(135deg, #be185d, #ec4899); color: #fff; padding: 36px 0; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; text-align: center; }
.stat-item h3 { font-size: 1.7rem; margin-bottom: 4px; }
.cta { padding: 40px 0; text-align: center; background: var(--bg-card); }
.footer { background: #18181b; color: #a1a1aa; padding: 20px 0; text-align: center; font-size: .82rem; }
.login-container { max-width: 360px; margin: 60px auto; padding: 28px; background: var(--bg-card); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.login-header { text-align: center; margin-bottom: 18px; }

/* --- Account Detail 레이아웃 --- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-form-4col { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; }

/* ============================================================
   반응형 — 태블릿
   ============================================================ */
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar { display: flex; }
    .topbar-menu { display: block; }
    .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 999; }
    .sidebar-overlay.active { display: block; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   반응형 — 모바일
   ============================================================ */
@media (max-width: 768px) {
    body { font-size: 13px; }
    .main-content { padding: 12px 10px; }

    /* 카드 */
    .card-body { padding: 12px; }
    .card-header { padding: 10px 12px; font-size: .88rem; }

    /* 그리드 */
    .resource-grid { grid-template-columns: repeat(2, 1fr); }
    .resource-grid.compact { grid-template-columns: repeat(2, 1fr); }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .krw-ally-grid { grid-template-columns: 1fr; }

    /* 폼 */
    .form-row { flex-direction: column; gap: 0; }
    .form-control { font-size: .88rem; padding: 9px 12px; }

    /* 탭 */
    .tab-nav { gap: 0; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
    .tab-nav::-webkit-scrollbar { display: none; }
    .tab-button { padding: 8px 12px; font-size: .8rem; flex-shrink: 0; }

    /* 테이블 가로 스크롤 */
    .table-responsive { overflow-x: auto; margin: 0 -12px; padding: 0 12px; }
    .accounts-table { min-width: 700px; }
    .accounts-table th, .accounts-table td { padding: 6px 4px; font-size: .76rem; }

    /* 모달 */
    .modal { width: 96vw; padding: 16px; }

    /* 상세 페이지 2단→1단 */
    .detail-grid { grid-template-columns: 1fr; }
    .detail-form-4col { grid-template-columns: 1fr 1fr; }
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* 페이지 헤더 */
    .page-header { flex-direction: column; gap: 6px; align-items: flex-start; }
    .page-title { font-size: 1.1rem; }

    /* 히어로 */
    .hero h1 { font-size: 1.5rem; }
    .hero p { font-size: .92rem; }
    .header .container { flex-direction: column; gap: 6px; }
    .user-resources { flex-direction: column; }
}

/* ============================================================
   반응형 — 소형 모바일
   ============================================================ */
@media (max-width: 480px) {
    .resource-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .btn { padding: 6px 10px; font-size: .8rem; }
    .stat-card .stat-value { font-size: 1.2rem; }
    .tab-button { padding: 6px 8px; font-size: .78rem; }
}

/* ============================================================
   스크롤바
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================================
   프린트
   ============================================================ */
@media print {
    .sidebar, .topbar, .sidebar-overlay, .btn, .dark-toggle { display: none !important; }
    .main { margin-left: 0 !important; }
    .card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
    body { background: #fff; color: #000; }
}
