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

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

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --bg: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(51, 65, 85, 0.7);
    /* 다이얼로그 패널(모달 본문): 항상 불투명 — 배경이 비치지 않게 */
    --modal-panel-bg: #1e293b;
    --modal-panel-bg-muted: #252b3d;
    --bg-sidebar: rgba(15, 23, 42, 0.95);
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --glass: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.08);
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 64px;
    --header-height: 60px;
    --footer-height: 40px;
    --surface-input: rgba(30, 41, 59, 0.95);
    --option-bg: #1e293b;
    --form-control-height-sm: 34px;
    --form-control-select-pr: 28px;
    --form-control-font-size: .875rem;
    --form-control-font-size-sm: .78rem;
}

html { color-scheme: dark; }

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

/* ===== Background Effects ===== */
.bg-effects { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-orb {
    position: absolute; border-radius: 50%; filter: blur(100px); opacity: 0.3;
    animation: orbFloat 20s ease-in-out infinite;
}
.bg-orb:nth-child(1) {
    width: 600px; height: 600px;
    background: radial-gradient(circle, #6366f1, transparent 70%);
    top: -200px; left: -100px; animation-duration: 25s;
}
.bg-orb:nth-child(2) {
    width: 500px; height: 500px;
    background: radial-gradient(circle, #8b5cf6, transparent 70%);
    bottom: -150px; right: -100px; animation-duration: 30s; animation-delay: -5s;
}
.bg-orb:nth-child(3) {
    width: 400px; height: 400px;
    background: radial-gradient(circle, #06b6d4, transparent 70%);
    top: 50%; left: 50%; animation-duration: 22s; animation-delay: -10s;
}
@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(80px, -60px) scale(1.1); }
    50% { transform: translate(-40px, 80px) scale(0.9); }
    75% { transform: translate(60px, 40px) scale(1.05); }
}

/* Particles */
.particles { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.particle {
    position: absolute; width: 3px; height: 3px;
    background: rgba(99, 102, 241, 0.6); border-radius: 50%;
    animation: particleRise linear infinite;
}
@keyframes particleRise {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    10% { opacity: 1; } 90% { opacity: 1; }
    100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* ===== 전역 헤더 ===== */
.app-header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    z-index: 150;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 20px 0 0;
    gap: 8px;
}
.header-left { display: flex; align-items: center; height: 100%; }
.header-toggle {
    width: 60px; height: 100%;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; border-right: 1px solid var(--border);
    color: var(--text-dim); font-size: 1.1rem; cursor: pointer;
    transition: all .3s; border-radius: 0; flex-shrink: 0;
}
.header-toggle:hover { background: var(--glass); color: var(--text); }
.app-brand {
    display: flex; align-items: baseline; gap: 8px;
    padding: 0 20px; text-decoration: none;
}
.brand-logo {
    font-size: 1.3rem; font-weight: 900;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: 3px;
}
.brand-sub {
    font-size: .6rem; color: var(--text-dim);
    letter-spacing: 3px; text-transform: uppercase;
}
.header-right { display: flex; align-items: center; gap: 12px; }
.header-date { font-size: .78rem; }
.header-cash {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    padding: 4px 10px; border-radius: 20px;
    font-size: .7rem; font-weight: 700; color: #fff; white-space: nowrap;
    text-decoration: none; transition: opacity .2s, transform .2s;
}
.header-cash:hover { opacity: .85; transform: translateY(-1px); }
.header-user {
    display: flex; align-items: center; gap: 10px;
    text-decoration: none; color: inherit;
    padding: 6px 10px; border-radius: 10px;
    transition: background .2s;
}
.header-user:hover { background: var(--glass); }
.header-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; flex-shrink: 0;
    animation: pulseGlow 3s ease-in-out infinite;
}
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
    50% { box-shadow: 0 0 20px 6px rgba(99, 102, 241, 0.2); }
}
.header-user-info { line-height: 1.3; }
.btn-header-logout {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-dim);
    cursor: pointer; font-size: .9rem; transition: all .3s; padding: 0;
}
.btn-header-logout:hover { border-color: var(--danger); color: var(--danger); background: rgba(239, 68, 68, 0.1); }

/* ===== Sidebar ===== */
.sidebar {
    position: fixed; left: 0; top: var(--header-height);
    width: var(--sidebar-width); height: calc(100vh - var(--header-height));
    background: var(--bg-sidebar);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    z-index: 100;
    display: flex; flex-direction: column;
    transition: width .3s ease, transform .3s ease;
    overflow: hidden;
}

/* 사이드바 접힘 상태 */
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .nav-label {
    opacity: 0; width: 0; overflow: hidden; white-space: nowrap;
}
.sidebar.collapsed .nav-section {
    opacity: 0; height: 0; padding: 0; overflow: hidden;
}
.sidebar.collapsed .nav-group-summary {
    display: none;
}
.sidebar.collapsed .nav-group {
    margin: 0; border: none; background: transparent;
}
.sidebar.collapsed .nav-group-body {
    padding: 0;
}
.sidebar.collapsed .nav-item a {
    justify-content: center; padding: 12px 0;
}
.sidebar.collapsed .nav-item a:hover,
.sidebar.collapsed .nav-item a.active { transform: none; }
.sidebar.collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 0; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-section {
    padding: 8px 20px 4px; font-size: .65rem; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: 2px; font-weight: 600;
    transition: opacity .3s, height .3s, padding .3s;
    white-space: nowrap;
}

/* 관리자 메뉴 접기/펼치기 그룹 */
.nav-group {
    margin: 4px 10px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}
.nav-group-summary {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    user-select: none;
    transition: color .2s, background .2s;
}
.nav-group-summary::-webkit-details-marker { display: none; }
.nav-group-summary:hover { color: var(--text); background: rgba(99, 102, 241, 0.12); }
.nav-group-title { flex: 1; min-width: 0; }
.nav-group-chevron {
    font-size: .6rem;
    opacity: .65;
    transition: transform .25s ease;
    flex-shrink: 0;
}
.nav-group[open] .nav-group-chevron { transform: rotate(180deg); }
.nav-group-body { padding: 2px 6px 10px; }
.nav-group .nav-item { margin: 2px 4px; }

.nav-item { margin: 2px 10px; }
.nav-item a {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; color: var(--text-dim); text-decoration: none;
    border-radius: 10px; font-size: .85rem; font-weight: 400;
    transition: all .3s cubic-bezier(.4, 0, .2, 1);
    position: relative; overflow: hidden; white-space: nowrap;
}
.nav-item a i { width: 20px; text-align: center; font-size: .9rem; flex-shrink: 0; }
.nav-item a::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    opacity: 0; transition: opacity .3s; border-radius: 10px;
}
.nav-item a:hover::before, .nav-item a.active::before { opacity: 1; }
.nav-item a:hover, .nav-item a.active { color: #fff; transform: translateX(4px); }
.nav-item a i, .nav-item a span { position: relative; z-index: 1; }
.nav-label { transition: opacity .3s, width .3s; }

/* 사이드바 접기 버튼 */
.sidebar-collapse-btn {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: 14px 20px;
    background: transparent; border: none; border-top: 1px solid var(--border);
    color: var(--text-dim); cursor: pointer; font-size: .9rem;
    transition: all .3s; border-radius: 0; flex-shrink: 0;
}
.sidebar-collapse-btn:hover { background: var(--glass); color: var(--text); }
.sidebar-collapse-btn i { transition: transform .3s ease; }

/* 사이드바 유저 영역 */
.sidebar-footer {
    padding: 14px 20px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0; overflow: hidden;
    transition: padding .3s;
}
.sidebar-footer .user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; flex-shrink: 0;
    animation: pulseGlow 3s ease-in-out infinite;
}
.sidebar-footer .user-info { flex: 1; min-width: 0; overflow: hidden; }
.sidebar-footer .user-name,
.sidebar-footer .user-role,
.sidebar-footer .cash-badge { transition: opacity .2s, width .2s; }

/* 접힘 상태에서 sidebar-footer: 아이콘만 보이게 */
.sidebar.collapsed .sidebar-footer {
    justify-content: center; padding: 14px 0;
}
.sidebar.collapsed .sidebar-footer .user-info,
.sidebar.collapsed .sidebar-footer .cash-badge { opacity: 0; width: 0; overflow: hidden; }

/* 공통 유저/캐시 스타일 */
.user-name { font-size: .8rem; font-weight: 600; }
.user-role { font-size: .65rem; color: var(--text-dim); }
.cash-badge {
    background: linear-gradient(135deg, #f59e0b, #f97316);
    padding: 4px 10px; border-radius: 20px;
    font-size: .7rem; font-weight: 700; color: #fff; white-space: nowrap;
}

/* Sidebar backdrop (mobile) */
.sidebar-backdrop {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 120;
}
.sidebar-backdrop.show { display: block; }

/* 전역 푸터 */
.app-footer {
    text-align: center; padding: 16px 0;
    color: var(--text-dim); font-size: .75rem;
    border-top: 1px solid var(--border); margin-top: 24px;
}

/* ===== Main Content ===== */
.main {
    margin-left: var(--sidebar-width);
    padding: 28px 32px;
    padding-top: calc(var(--header-height) + 28px);
    position: relative; z-index: 1;
    min-height: 100vh;
    transition: margin-left .3s ease;
    display: flex; flex-direction: column;
}
.main.sidebar-collapsed { margin-left: var(--sidebar-collapsed-width); }

/* ===== Page transition ===== */
.page-content { flex: 1; animation: pageIn .5s ease-out; }
@keyframes pageIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Top Bar ===== */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 28px; animation: fadeIn .6s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.topbar h1 { font-size: 1.4rem; font-weight: 700; }
.topbar h1 small { font-size: .75rem; color: var(--text-dim); font-weight: 400; margin-left: 8px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.date-badge {
    background: var(--bg-card); border: 1px solid var(--border);
    padding: 8px 16px; border-radius: 10px;
    font-size: .8rem; color: var(--text-dim);
}

/* ===== Cards / Panels ===== */
.card, .panel, .table-wrap {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
}
.card:hover, .panel:hover { border-color: rgba(99, 102, 241, 0.2); }

/* ===== Stat Cards ===== */
.stat-cards-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}
.stat-card {
    background: var(--bg-card); backdrop-filter: blur(16px);
    border: 1px solid var(--border); border-radius: 14px;
    padding: 20px; position: relative; overflow: hidden;
    transition: all .4s cubic-bezier(.4, 0, .2, 1);
    opacity: 0; transform: translateY(30px);
    animation: cardIn .6s cubic-bezier(.4, 0, .2, 1) forwards;
}
.stat-card:nth-child(1) { animation-delay: .1s; }
.stat-card:nth-child(2) { animation-delay: .15s; }
.stat-card:nth-child(3) { animation-delay: .2s; }
.stat-card:nth-child(4) { animation-delay: .25s; }
.stat-card:nth-child(5) { animation-delay: .3s; }
@keyframes cardIn { to { opacity: 1; transform: translateY(0); } }

.stat-card:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: rgba(99, 102, 241, 0.3);
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.3), 0 0 20px rgba(99, 102, 241, 0.1);
}
/* 상단 컬러 바 */
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    border-radius: 14px 14px 0 0;
}
.stat-card.purple::before  { background: linear-gradient(90deg, #6366f1, #818cf8); }
.stat-card.green::before   { background: linear-gradient(90deg, #10b981, #34d399); }
.stat-card.amber::before   { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.stat-card.red::before     { background: linear-gradient(90deg, #ef4444, #f87171); }
.stat-card.cyan::before    { background: linear-gradient(90deg, #06b6d4, #22d3ee); }

/* 그라디언트 강조 카드 */
.stat-card.highlight-purple {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none; color: #fff;
}
.stat-card.highlight-blue {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
    border: none; color: #fff;
}
.stat-card.highlight-purple::before,
.stat-card.highlight-blue::before { display: none; }

.stat-card .card-head {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.stat-card .card-icon {
    width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.stat-card.purple .card-icon  { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.stat-card.green .card-icon   { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.stat-card.amber .card-icon   { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.stat-card.red .card-icon     { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.stat-card.cyan .card-icon    { background: rgba(6, 182, 212, 0.2); color: #22d3ee; }

.stat-card .card-icon-right {
    width: 44px; height: 44px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}
.stat-card:not(.highlight-purple):not(.highlight-blue) .card-icon-right {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
}
.stat-card .card-label { font-size: .75rem; color: var(--text-dim); }
.stat-card.highlight-purple .card-label,
.stat-card.highlight-blue .card-label { color: rgba(255, 255, 255, 0.82); }
.stat-card .card-value { font-size: 1.8rem; font-weight: 700; margin-top: 4px; }
.stat-card.highlight-purple .card-value,
.stat-card.highlight-blue .card-value { color: #fff; }
.stat-card .card-sub { font-size: .7rem; color: var(--text-dim); margin-top: 4px; }
.stat-card.highlight-purple .card-sub,
.stat-card.highlight-blue .card-sub { color: rgba(255, 255, 255, 0.75); }
.stat-card .card-change {
    display: inline-block; font-size: .72rem; font-weight: 600;
    padding: 2px 8px; border-radius: 8px; margin-left: 8px;
}
.card-change.up  { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.card-change.down { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.stat-card.highlight-purple .card-change.up,
.stat-card.highlight-blue .card-change.up { background: rgba(255, 255, 255, 0.2); color: #bbf7d0; }
.stat-card.highlight-purple .card-change.down,
.stat-card.highlight-blue .card-change.down { background: rgba(255, 255, 255, 0.2); color: #fecaca; }

/* ===== Section Title ===== */
.section-title {
    font-size: 1.1rem; font-weight: 700; margin: 28px 0 16px;
    display: flex; align-items: center; gap: 10px;
}
.section-title::before {
    content: ''; width: 4px; height: 20px;
    background: linear-gradient(180deg, var(--primary), #8b5cf6);
    border-radius: 2px; flex-shrink: 0;
}
/* h3 수준 섹션 타이틀 (카드 내부 제목) */
.section-title--tight { margin-bottom: 12px; }
.section-title--compact { margin-bottom: 10px; }
.section-title--flush { margin: 0; }

.section-head {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.section-head .btn { text-decoration: none; }
.section-meta { font-size: .75rem; color: var(--text-dim); }

/* ===== Row Grid ===== */
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 140px; }

/* ===== Form Elements ===== */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-input);
    color: var(--text);
    font-family: inherit;
    font-size: var(--form-control-font-size);
    transition: border-color .3s, box-shadow .3s;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }

select {
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    padding-right: var(--form-control-select-pr); cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 14px;
    background-color: var(--surface-input);
}
select option, select optgroup {
    background-color: var(--option-bg);
    color: var(--text);
    font-size: inherit;
}

/* 필터바 내 select/input 은 컨텐츠 폭에 맞게 */
.filter-bar select,
.filter-bar input[type="text"],
.filter-bar input[type="search"] {
    width: auto;
}
.filter-bar input[type="text"],
.filter-bar input[type="search"],
.filter-bar input[type="number"],
.filter-bar input[type="date"] {
    height: var(--form-control-height-sm);
    padding: 0 12px;
    font-size: var(--form-control-font-size-sm);
}
.filter-bar select {
    height: var(--form-control-height-sm);
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 10px;
    padding-right: var(--form-control-select-pr);
    background-position: right 8px center;
    font-size: var(--form-control-font-size-sm);
}
.filter-bar .btn,
.filter-bar a.btn,
.filter-bar button {
    height: var(--form-control-height-sm);
    padding: 0 12px;
    line-height: 1;
    font-size: var(--form-control-font-size-sm);
}

/* 운영 페이지 공통 필터 카드 (cash/missions/rank-items 공통 폭 규칙) */
.page-filter-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 16px;
}
.page-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.page-filter-row-period {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}
.page-filter-form select,
.page-filter-form input[type="text"],
.page-filter-form input[type="search"],
.page-filter-form input[type="date"] {
    width: auto;
    min-width: 0;
    height: var(--form-control-height-sm);
    border-radius: 8px;
    font-size: var(--form-control-font-size-sm);
}
.page-filter-form input[type="text"],
.page-filter-form input[type="search"],
.page-filter-form input[type="date"] {
    padding: 0 10px;
}
.page-filter-form select {
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 8px;
    padding-right: var(--form-control-select-pr);
    background-position: right 8px center;
}
.page-filter-form select { width: 122px; }
.page-filter-form input[type="text"],
.page-filter-form input[type="search"] { width: 110px; }
.page-filter-form input[type="date"] { width: 142px; }
.page-filter-form .btn,
.page-filter-form a.btn,
.page-filter-form button {
    height: var(--form-control-height-sm);
    padding: 0 12px;
    border-radius: 8px;
    font-size: var(--form-control-font-size-sm);
    line-height: 1;
}
.page-filter-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin-left: 6px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
}
.page-filter-preset-btn {
    height: var(--form-control-height-sm);
    padding: 0 9px;
    border-radius: 7px;
    border: 1px solid var(--border);
    background: var(--surface-input);
    color: var(--text-dim);
    font-size: var(--form-control-font-size-sm);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
}
.page-filter-preset-btn:hover {
    border-color: var(--primary);
    color: var(--primary-light);
}
@media (max-width: 900px) {
    .page-filter-presets {
        width: 100%;
        margin-left: 0;
        margin-top: 6px;
        padding-left: 0;
        padding-top: 8px;
        border-left: none;
        border-top: 1px solid var(--border);
    }
}

select:focus,
input:not([type="checkbox"]):not([type="radio"]):focus,
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.22); }
select:hover:not(:disabled),
input:not([type="checkbox"]):not([type="radio"]):hover:not(:disabled),
textarea:hover:not(:disabled) { border-color: rgba(129, 140, 248, 0.35); }
input:not([type="checkbox"]):not([type="radio"]):disabled,
select:disabled, textarea:disabled { opacity: 0.55; cursor: not-allowed; }
input::placeholder, textarea::placeholder { color: rgba(148, 163, 184, 0.55); }
input:-webkit-autofill, input:-webkit-autofill:hover, input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--text);
    box-shadow: 0 0 0 1000px var(--option-bg) inset;
    transition: background-color 99999s ease-out;
}

/* 카드·패널 내 폼 라벨 */
.card form label, .panel form label,
.login-box .form-group label {
    display: block; font-size: .75rem; color: var(--text-dim);
    margin-bottom: 6px; font-weight: 500;
}
/* 카드 내 폼 버튼 상단 여백 */
.card form > .btn-primary { margin-top: 14px; }
.card form > .form-actions-bar { margin-top: 14px; }
.field-grow-2 { flex: 2 1 0; min-width: 140px; }

/* ===== Buttons ===== */
button {
    cursor: pointer; width: auto; padding: 10px 16px;
    border-radius: 10px; border: 1px solid var(--border);
    background: var(--glass); color: var(--text);
    font-family: inherit; font-size: .875rem;
    transition: all .3s;
}
.btn {
    padding: 12px 20px; border-radius: 10px;
    font-size: .85rem; font-weight: 600; cursor: pointer;
    font-family: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    text-decoration: none; transition: all .3s;
    border: 1px solid var(--border);
}
.btn-primary {
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: #fff; border: none;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(99, 102, 241, 0.4); }
.btn-primary.app-confirm-btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}
.btn-primary.app-confirm-btn-danger:hover { box-shadow: 0 8px 24px rgba(239, 68, 68, 0.35); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); background: rgba(99, 102, 241, 0.1); }
.btn-sm { padding: 6px 12px; font-size: .75rem; border-radius: 8px; }
.btn-cash {
    background: linear-gradient(135deg, #f59e0b, #f97316); color: #fff; border: none;
}
.btn-cash:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(245, 158, 11, 0.4); }

/* 파일 다운로드 버튼 공통 스타일 (CSV/XLSX) */
.btn-file-download,
.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--form-control-height-sm);
    padding: 0 14px;
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    font-family: inherit;
    font-size: var(--form-control-font-size-sm);
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, border-color .2s, color .2s;
}
.btn-file-download:hover,
.download-btn:hover {
    background: rgba(16, 185, 129, 0.25);
    border-color: rgba(16, 185, 129, 0.45);
    color: #34d399;
}
.download-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* 폼 액션 바 */
.form-actions-bar { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.form-actions-hint { font-size: .75rem; color: var(--text-dim); }

/* 페이지 하단 중앙 저장 버튼 영역 */
.page-save-bar {
    display: flex; justify-content: center; align-items: center;
    gap: 12px; margin-top: 32px; padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* 테이블 직상단 건수·페이지 요약 (사용자 관리 등 공통) */
.result-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 12px;
    margin-bottom: 12px;
    font-size: .8rem;
    color: var(--text-dim);
    min-width: 0;
}
.result-bar--start { justify-content: flex-start; }
.result-bar strong { color: var(--text); }

/* ===== Data Table ===== */
.data-table, table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td,
table th, table td {
    text-align: left; padding: 10px 12px; font-size: .8rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.data-table th, table th {
    color: var(--text-dim); border-bottom: 1px solid var(--border);
    font-size: .7rem; font-weight: 500; text-transform: uppercase; letter-spacing: 1px;
}
.data-table tbody tr, table tbody tr { transition: all .2s; }
.data-table tbody tr:hover, table tbody tr:hover { background: rgba(99, 102, 241, 0.07); }
.table-empty { text-align: center; color: var(--text-dim); padding: 28px; }

/* ===== Badges ===== */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: .68rem; font-weight: 600; letter-spacing: .3px;
}
.badge.success { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge.warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.badge.info    { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.badge.danger  { background: rgba(239, 68, 68, 0.15); color: #f87171; }

/* ===== Login ===== */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; position: relative; z-index: 1; }
.login-box {
    background: var(--bg-card); backdrop-filter: blur(20px);
    border: 1px solid var(--border); border-radius: 24px;
    padding: 48px 40px; width: 420px; max-width: 95vw;
    text-align: center; animation: modalIn .6s cubic-bezier(.4, 0, .2, 1);
}
.login-box h1 {
    font-size: 2rem; font-weight: 900;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    letter-spacing: 4px; margin-bottom: 4px;
}
.login-sub { font-size: .8rem; color: var(--text-dim); margin-bottom: 32px; }
.login-options {
    display: flex; flex-wrap: wrap; gap: 14px 20px; justify-content: flex-start;
    margin: 4px 0 8px; text-align: left; font-size: .78rem; color: var(--text-dim);
}
.login-option {
    display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
    font-weight: 500; color: var(--text-dim);
}
.login-option input[type="checkbox"] { width: auto; margin: 0; cursor: pointer; accent-color: var(--primary); }
.form-group { margin-bottom: 16px; text-align: left; }
.form-group input {
    padding: 12px 16px; font-size: .9rem; transition: all .3s;
}
.password-input-wrap {
    position: relative; display: flex; align-items: center;
}
.password-input-wrap input {
    width: 100%; padding-right: 44px;
}
.password-toggle-btn {
    position: absolute; right: 10px;
    width: 28px; height: 28px; border: none;
    border-radius: 8px; background: transparent; color: var(--text-dim);
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.password-toggle-btn:hover { color: #d1d5db; background: rgba(255, 255, 255, 0.07); }
.login-help-btn {
    border: none; background: transparent; color: #a5b4fc;
    cursor: pointer; padding: 0; font-size: .82rem;
    display: inline-flex; align-items: center; justify-content: center;
}
.login-help-btn:hover { color: #c4b5fd; }
.login-tooltip {
    margin: 0 0 10px;
    padding: 10px 12px;
    border: 1px solid rgba(129, 140, 248, 0.45);
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.12);
    color: #dbeafe;
    text-align: left;
    font-size: .78rem;
    line-height: 1.45;
}
.login-btn {
    width: 100%; padding: 14px; margin-top: 8px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    border: none; border-radius: 12px; color: #fff;
    font-size: .95rem; font-weight: 700; font-family: inherit;
    cursor: pointer; letter-spacing: 1px; transition: all .3s;
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(99, 102, 241, 0.4); }

.error {
    margin-bottom: 12px; padding: 10px 12px; border-radius: 10px;
    background: rgba(239, 68, 68, 0.2); border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fecaca; text-align: left; font-size: .8rem;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 500;
    display: none; align-items: center; justify-content: center;
    animation: fadeIn .3s;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--modal-panel-bg);
    border: 1px solid var(--border); border-radius: 20px;
    padding: 32px; width: 480px; max-width: 95vw;
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5);
    animation: modalIn .4s cubic-bezier(.4, 0, .2, 1);
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: 6px; }
.modal .modal-sub { font-size: .8rem; color: var(--text-dim); margin-bottom: 24px; }
.modal-close {
    position: absolute; top: 16px; right: 20px;
    background: none; border: none; color: var(--text-dim);
    font-size: 1.3rem; cursor: pointer; transition: color .2s;
}
.modal-close:hover { color: #fff; }
.logout-modal-inner { position: relative; }
.modal-actions {
    display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end;
    margin-top: 8px;
}

/* 모달 폼 컨트롤 공통 규칙 (페이지별 로컬 오버라이드 최소화) */
.modal form input:not([type="checkbox"]):not([type="radio"]),
.modal form select {
    height: var(--form-control-height-sm);
    font-size: var(--form-control-font-size-sm);
}
.modal form input:not([type="checkbox"]):not([type="radio"]) {
    padding: 0 12px;
}
.modal form select {
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 10px;
    padding-right: var(--form-control-select-pr);
    background-position: right 8px center;
}
.modal form textarea {
    font-size: var(--form-control-font-size-sm);
}
.modal form .btn,
.modal form a.btn,
.modal form button:not(.modal-close):not(.pw-toggle):not(.password-toggle-btn) {
    height: var(--form-control-height-sm);
    padding: 0 12px;
    font-size: var(--form-control-font-size-sm);
    line-height: 1;
}

/* ===== Toast ===== */
.toast {
    position: fixed; top: calc(var(--header-height) + 12px); right: 24px; z-index: 600;
    padding: 14px 24px; border-radius: 12px; font-size: .85rem; font-weight: 500;
    backdrop-filter: blur(10px); animation: toastIn .4s ease-out; display: none;
}
.toast.show { display: block; }
.toast.success { background: rgba(16, 185, 129, 0.2); border: 1px solid rgba(16, 185, 129, 0.3); color: #34d399; }
.toast.error   { background: rgba(239, 68, 68, 0.2); border: 1px solid rgba(239, 68, 68, 0.3); color: #f87171; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* ===== KPI mini cards (목록 상단 요약 카드) ===== */
.kpi-mini-label { font-size: .72rem; color: var(--text-dim); }
.kpi-mini-value { font-size: 1.5rem; font-weight: 700; margin-top: 4px; line-height: 1.2; }
.kpi-mini-value--sm { font-size: 1.45rem; }
.kpi-mini-value--md { font-size: 1.2rem; }
.kpi-mini-value--lg { font-size: 1.6rem; }
.text-kpi-indigo  { color: #818cf8; }
.text-kpi-emerald { color: #34d399; }
.text-kpi-rose    { color: #f87171; }
.text-kpi-cyan    { color: #22d3ee; }
.text-kpi-amber   { color: #fbbf24; }

/* ===== Step cards (미션 등록) ===== */
.step-card--indigo  { background: rgba(99, 102, 241, 0.08); border-color: rgba(99, 102, 241, 0.25); }
.step-card--emerald { background: rgba(16, 185, 129, 0.08); border-color: rgba(16, 185, 129, 0.25); }
.step-card--amber   { background: rgba(245, 158, 11, 0.08); border-color: rgba(245, 158, 11, 0.25); }
.step-card-index { font-size: .72rem; color: var(--text-dim); }
.step-card-title { font-size: .92rem; font-weight: 700; }

/* ===== 패널 유틸 ===== */
.panel-title-icon { color: var(--primary-light); margin-right: 6px; }
.panel-lead  { color: var(--text-dim); font-size: .82rem; line-height: 1.8; }
.panel-note  { font-size: .78rem; color: var(--text-dim); line-height: 1.7; }
.panel-note--lead { font-size: .82rem; line-height: 1.7; margin-bottom: 16px; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.panel-actions .btn { text-decoration: none; }
.hint-footnote { margin-top: 8px; color: var(--text-dim); font-size: .78rem; }
.muted-p { margin-bottom: 10px; color: var(--text-dim); }
.textarea-code { width: 100%; font-family: ui-monospace, 'Consolas', monospace; }

/* ===== 마이페이지 프로필 ===== */
.profile-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.profile-identity { display: flex; align-items: center; gap: 14px; }
.profile-avatar-lg {
    width: 56px; height: 56px; border-radius: 14px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; font-weight: 700; color: #fff;
}
.profile-name { font-size: 1rem; font-weight: 700; }
.profile-meta-line { font-size: .75rem; color: var(--text-dim); margin-top: 2px; }
.profile-balance { text-align: right; }

/* ===== 유틸 ===== */
.u-hidden { display: none; }

/* ===== Impersonation (헤더 내부 — 전역 모달(z-index)보다 낮은 레이어) ===== */
.header-impersonate {
    flex: 1;
    min-width: 0;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 6px;
    flex-wrap: nowrap;
    overflow: hidden;
}
.header-impersonate-text {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
    flex-wrap: nowrap;
    white-space: nowrap;
    overflow: hidden;
    font-size: .72rem;
    color: #fef3c7;
    line-height: 1;
    background: linear-gradient(90deg, rgba(146, 64, 14, 0.9), rgba(180, 83, 9, 0.78));
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid rgba(254, 243, 199, 0.22);
}
.header-impersonate-text i {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.header-impersonate-text strong { flex-shrink: 0; font-weight: 700; }
.header-impersonate-label { flex-shrink: 0; font-weight: 600; opacity: 0.95; }
.header-impersonate-origin {
    flex: 1;
    min-width: 0;
    font-size: .68rem;
    opacity: 0.85;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}
.header-impersonate-form {
    flex-shrink: 0;
    margin: 0;
    padding: 0;
    border: 0;
    display: flex;
    align-items: center;
}
.btn-imp-restore {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 8px;
    margin: 0;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.32);
    color: #fef3c7;
    font-size: .72rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.2;
    box-sizing: border-box;
}
.btn-imp-restore:hover { background: rgba(255, 255, 255, 0.3); }
body.is-impersonating .sidebar,
body.is-impersonating .main { top: var(--header-height); }
body.is-impersonating .app-header { top: 0; }

@media (max-width: 900px) {
    .header-impersonate-text { font-size: .68rem; padding: 4px 10px; }
    .btn-imp-restore { font-size: .68rem; padding: 4px 8px; }
}
@media (max-width: 600px) {
    .header-impersonate { gap: 6px; padding: 0 4px; }
    .header-impersonate-text { font-size: .62rem; padding: 4px 8px; gap: 4px; }
    .btn-imp-restore { font-size: .62rem; padding: 3px 8px; }
}

/* ===== Docs Tab Navigation ===== */
.docs-tab-nav {
    display: flex; gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 28px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.docs-tab-nav::-webkit-scrollbar { height: 0; }
.docs-tab {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 20px;
    font-size: .85rem; font-weight: 500;
    color: var(--text-dim);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .2s, background .2s, border-color .2s;
    white-space: nowrap; flex-shrink: 0;
}
.docs-tab i { font-size: .8rem; }
.docs-tab:hover { color: var(--text); background: var(--glass); }
.docs-tab.active {
    color: var(--primary-light);
    border-bottom-color: var(--primary-light);
    background: rgba(99, 102, 241, 0.06);
}
.docs-tab-content { min-height: 400px; }

/* ===== 날짜 입력 (필터·툴바·폼) =====
   PC에서 내용(YYYY-MM-DD)에 맞는 고정 폭. flex 줄에서 가로로 끝없이 늘어나지 않게 함. */
.filter-bar input[type="date"],
form.filter-bar input[type="date"],
.am-filter-form input[type="date"] {
    width: 9.5rem;
    min-width: 8.75rem;
    max-width: 11rem;
    flex: 0 0 auto;
    color-scheme: dark;
    box-sizing: border-box;
}

/* 일반 폼: 컬럼이 넓어도 날짜 칸만 과도하게 퍼지지 않도록 상한 */
.form-row .field input[type="date"] {
    width: 100%;
    max-width: 11rem;
    color-scheme: dark;
    box-sizing: border-box;
}

/* ===== Responsive ===== */
@media (max-width: 1100px) {
    .stat-cards-row { grid-template-columns: repeat(2, 1fr) !important; }
}
@media (max-width: 900px) {
    .brand-sub { display: none; }
    .header-user-info { display: none; }
    .header-date { display: none; }
}
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px !important; /* collapsed 무시 */
        z-index: 130;
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-collapse-btn { display: none; }
    .main {
        margin-left: 0 !important; /* collapsed 무시 */
        padding: 14px;
        padding-top: calc(var(--header-height) + 14px);
    }
    .topbar { flex-direction: column; gap: 10px; align-items: flex-start; }
    .topbar h1 { font-size: 1.15rem; }
    .topbar h1 small { display: block; margin-left: 0; margin-top: 2px; }
    .topbar-right { width: 100%; justify-content: space-between; }
    .stat-cards-row { grid-template-columns: 1fr !important; }
    .stat-card .card-value { font-size: 1.4rem; }
    .toast { left: 16px; right: 16px; top: auto; bottom: 24px; text-align: center; }
}
@media (max-width: 400px) {
    .stat-cards-row { gap: 10px; }
}
