/* 299본부 성과관리 CRM - 스타일시트 */

/* CSS Variables - Light Theme (Default) */
:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --gold: #d97706;
    --gold-light: #f59e0b;
    --gold-dark: #b45309;
    --silver: #6b7280;
    --silver-light: #9ca3af;
    --bronze: #b45309;
    --bronze-light: #d97706;
    --success: #16a34a;
    --error: #dc2626;
    --info: #2563eb;
    --border-color: #e2e8f0;
}

/* CSS Variables - Dark Theme */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --gold: #fbbf24;
    --gold-light: #fcd34d;
    --gold-dark: #d97706;
    --silver: #9ca3af;
    --silver-light: #d1d5db;
    --bronze: #cd7f32;
    --bronze-light: #d4a373;
    --success: #22c55e;
    --error: #ef4444;
    --info: #3b82f6;
    --border-color: #334155;
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle-track {
    position: relative;
    width: 48px;
    height: 24px;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.theme-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: var(--gold);
    border-radius: 50%;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.theme-toggle-thumb::before {
    content: '☀️';
}

[data-theme="dark"] .theme-toggle-thumb {
    left: calc(100% - 20px);
}

[data-theme="dark"] .theme-toggle-thumb::before {
    content: '🌙';
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.3;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

/* Layout */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 1rem;
}

.dashboard-container {
    padding: 1rem;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
}

.card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    padding: 1rem;
}

/* Hall of Fame */
.hall-of-fame {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (max-width: 1200px) {
    .hall-of-fame {
        grid-template-columns: repeat(3, 1fr);
        max-width: 600px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .hall-of-fame {
        grid-template-columns: repeat(2, 1fr);
        max-width: 400px;
    }
}

.fame-card {
    border-radius: 16px;
    aspect-ratio: 3 / 4;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.fame-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        transparent 0%,
        transparent 30%,
        rgba(0,0,0,0.4) 60%,
        rgba(0,0,0,0.85) 100%
    );
    z-index: 1;
}

.fame-card-content {
    position: relative;
    z-index: 2;
    padding: 1rem;
    text-align: left;
}

.fame-category {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10;
    display: inline-block;
    font-size: 0.75rem;
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    padding: 0.3rem 0.625rem;
    border-radius: 4px;
}

.fame-profile {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.fame-profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fame-profile-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    opacity: 0.3;
}

.fame-name {
    font-size: 1rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.125rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.fame-team {
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 0.5rem;
}

.fame-score {
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1;
}

.fame-value {
    font-size: 0.625rem;
    color: rgba(255,255,255,0.6);
    margin-top: 0.125rem;
}

/* Ranking Table */
.ranking-table-wrapper {
    overflow-x: auto;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9375rem;
}

.ranking-table th,
.ranking-table td {
    padding: 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.ranking-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.ranking-table tbody tr {
    transition: background-color 0.2s ease;
}

.ranking-table tbody tr:hover {
    background: rgba(251, 191, 36, 0.05);
}

/* Rank Styles */
.rank-cell {
    font-weight: 700;
    font-size: 1.125rem;
}

.rank-1 {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2) 0%, rgba(251, 191, 36, 0.05) 100%) !important;
}

.rank-1 .rank-cell {
    color: var(--gold);
}

.rank-2 {
    background: linear-gradient(135deg, rgba(156, 163, 175, 0.15) 0%, rgba(156, 163, 175, 0.05) 100%) !important;
}

.rank-2 .rank-cell {
    color: var(--silver-light);
}

.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.15) 0%, rgba(205, 127, 50, 0.05) 100%) !important;
}

.rank-3 .rank-cell {
    color: var(--bronze-light);
}

/* Agent Cell */
.agent-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-align: left;
}

.agent-profile {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-tertiary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agent-profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.agent-profile-placeholder {
    color: var(--text-muted);
    font-size: 1rem;
}

.agent-info {
    min-width: 0;
}

.agent-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-team {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Score Cells */
.score-cell {
    font-weight: 600;
    color: var(--text-primary);
}

.score-highlight {
    color: var(--gold);
    font-weight: 700;
}

.score-premium {
    font-size: 0.875rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: #ffffff;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.btn-icon {
    padding: 0.5rem;
    width: 36px;
    height: 36px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

@media (max-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-value.gold {
    color: var(--gold);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

select.form-control {
    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='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-secondary);
    border-radius: 1rem;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.modal-text-content {
    line-height: 1.8;
    color: var(--text-primary);
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    border-left: 4px solid var(--info);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--error);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

/* Utilities */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-gold { color: var(--gold); }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 0.75rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

/* Admin Sidebar */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    display: block;
    padding: 0.875rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(251, 191, 36, 0.1);
    color: var(--gold);
    border-right: 3px solid var(--gold);
}

.nav-item svg {
    width: 20px;
    height: 20px;
}

.admin-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
}

/* Responsive - Tablet */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .admin-content {
        margin-left: 0;
    }

    .ranking-table {
        font-size: 0.8125rem;
    }

    .ranking-table th,
    .ranking-table td {
        padding: 0.75rem 0.5rem;
    }

    /* Header Mobile */
    .header {
        padding: 0.75rem 0;
    }

    .header-content {
        flex-direction: column;
        gap: 0.75rem;
    }

    .logo-text {
        font-size: 1.25rem;
    }

    .logo-subtitle {
        font-size: 0.75rem;
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap;
    }

    /* Stats Grid Mobile */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    /* Dashboard */
    .dashboard-container {
        padding: 1rem 0.5rem;
    }

    /* Cards */
    .card-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .card-title {
        font-size: 1rem;
    }

    .card-body {
        padding: 1rem;
    }
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    h3 { font-size: 1.125rem; }

    .container {
        padding: 0 0.5rem;
    }

    /* Header Mobile Small */
    .header-content {
        gap: 0.5rem;
    }

    .logo {
        text-align: center;
        width: 100%;
        justify-content: center;
    }

    .logo-text {
        font-size: 1.125rem;
    }

    .logo-subtitle {
        display: none;
    }

    .header-actions {
        gap: 0.25rem;
    }

    .header-actions .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .header-actions .btn svg {
        width: 14px;
        height: 14px;
    }

    .header-actions .btn-text {
        display: none;
    }

    .live-indicator {
        font-size: 0.7rem;
        gap: 0.25rem;
    }

    .live-indicator #last-updated {
        display: none;
    }

    /* Stats Grid Mobile Small */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.75rem;
    }

    .stat-value {
        font-size: 1.125rem;
    }

    /* Hall of Fame Mobile */
    .hall-of-fame {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .fame-card {
        border-radius: 12px;
    }

    .fame-card-content {
        padding: 0.75rem;
    }

    .fame-name {
        font-size: 0.875rem;
    }

    .fame-score {
        font-size: 1rem;
    }

    .fame-category {
        font-size: 0.625rem;
        padding: 0.2rem 0.5rem;
        top: 0.5rem;
        left: 0.5rem;
    }

    .fame-value {
        font-size: 0.5rem;
    }

    /* Ranking Table Mobile - 카드형 레이아웃 */
    .ranking-table-wrapper {
        overflow: visible;
    }

    .ranking-table-wrapper::after {
        display: none;
    }

    .ranking-table {
        display: block;
        min-width: unset;
    }

    .ranking-table thead {
        display: none;
    }

    .ranking-table tbody {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }

    .ranking-table tbody tr {
        display: grid;
        grid-template-columns: 36px 1fr auto;
        grid-template-rows: auto auto;
        gap: 0.25rem 0.5rem;
        background: var(--bg-tertiary);
        border-radius: 0.75rem;
        padding: 0.75rem;
        border: 1px solid var(--border-color);
    }

    .ranking-table tbody tr:hover {
        background: var(--bg-tertiary);
    }

    /* 1등, 2등, 3등 스타일 */
    .ranking-table tbody tr.rank-1 {
        border: 2px solid var(--gold);
        background: linear-gradient(135deg, rgba(251, 191, 36, 0.15) 0%, var(--bg-tertiary) 100%);
    }

    .ranking-table tbody tr.rank-2 {
        border: 2px solid var(--silver);
        background: linear-gradient(135deg, rgba(156, 163, 175, 0.1) 0%, var(--bg-tertiary) 100%);
    }

    .ranking-table tbody tr.rank-3 {
        border: 2px solid var(--bronze);
        background: linear-gradient(135deg, rgba(205, 127, 50, 0.1) 0%, var(--bg-tertiary) 100%);
    }

    .ranking-table tbody td {
        padding: 0;
        border: none;
        text-align: left;
    }

    /* 순위 셀 */
    .ranking-table tbody td:nth-child(1) {
        grid-row: 1 / 3;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        font-weight: 800;
    }

    /* 설계사 셀 */
    .ranking-table tbody td:nth-child(2) {
        grid-column: 2;
        grid-row: 1;
    }

    .ranking-table tbody td:nth-child(2) .agent-cell {
        gap: 0.5rem;
    }

    .ranking-table tbody td:nth-child(2) .agent-profile {
        width: 36px;
        height: 36px;
    }

    .ranking-table tbody td:nth-child(2) .agent-name {
        font-size: 0.9375rem;
        font-weight: 600;
    }

    .ranking-table tbody td:nth-child(2) .agent-team {
        display: block;
        font-size: 0.75rem;
    }

    /* 최종합계 셀 */
    .ranking-table tbody td:nth-child(10) {
        grid-column: 3;
        grid-row: 1;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        justify-content: center;
    }

    .ranking-table tbody td:nth-child(10) .score-highlight {
        font-size: 1.25rem;
        font-weight: 800;
    }

    /* 숨길 세부 점수 영역 (조기가동, 3W, 성장률, 이벤트, 근태) */
    .ranking-table tbody td:nth-child(3),
    .ranking-table tbody td:nth-child(6),
    .ranking-table tbody td:nth-child(7),
    .ranking-table tbody td:nth-child(8),
    .ranking-table tbody td:nth-child(9) {
        display: none;
    }

    /* 월납/건수 표시 (2번째 줄) */
    .ranking-table tbody td:nth-child(4),
    .ranking-table tbody td:nth-child(5) {
        grid-row: 2;
        font-size: 0.75rem;
        color: var(--text-secondary);
    }

    .ranking-table tbody td:nth-child(4) {
        grid-column: 2;
        text-align: left;
    }

    .ranking-table tbody td:nth-child(4)::before {
        content: '월납 ';
        color: var(--text-muted);
        font-size: 0.625rem;
    }

    .ranking-table tbody td:nth-child(5) {
        grid-column: 3;
        text-align: right;
    }

    .ranking-table tbody td:nth-child(5)::before {
        content: '건수 ';
        color: var(--text-muted);
        font-size: 0.625rem;
    }

    /* 세부 점수 표시용 영역 (3번째 줄) - 기본 숨김 */
    .ranking-table tbody tr::after {
        content: attr(data-details);
        grid-column: 2 / 4;
        grid-row: 3;
        font-size: 0.6875rem;
        color: var(--text-muted);
        padding-top: 0.25rem;
        display: none;
    }

    /* 점수확인 활성화 시 표시 */
    .ranking-table.show-scores tbody tr::after {
        display: block;
    }

    .ranking-table.show-scores tbody tr {
        grid-template-rows: auto auto auto;
    }

    /* Sort Buttons */
    .card-header .flex {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .card-header .btn-sm {
        padding: 0.375rem 0.5rem;
        font-size: 0.7rem;
    }

    /* Buttons */
    .btn-sm {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    /* Footer */
    footer {
        padding: 1rem !important;
        font-size: 0.75rem !important;
    }

    /* Admin Mobile */
    .admin-layout {
        flex-direction: column;
    }

    .admin-content {
        padding: 1rem;
    }

    .admin-content h1 {
        font-size: 1.25rem;
    }

    /* Modal Mobile */
    .modal {
        margin: 0.5rem;
        max-height: calc(100vh - 1rem);
    }

    .modal-body {
        padding: 1rem;
    }

    .form-group {
        margin-bottom: 1rem;
    }

    .form-control {
        padding: 0.625rem 0.75rem;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }
}

/* Print Styles */
@media print {
    .header,
    .btn,
    .sidebar {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.25rem;
    text-transform: uppercase;
}

.badge-success {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.badge-error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

.badge-gold {
    background: rgba(251, 191, 36, 0.2);
    color: var(--gold);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Live Indicator */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--success);
}

.live-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.75rem 1.25rem;
    color: var(--text-muted);
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

/* Quarter Header */
.quarter-header {
    text-align: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-radius: 0.75rem;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.quarter-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold), var(--gold-dark));
}

.quarter-title {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.25rem;
}

.quarter-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .quarter-header {
        padding: 1.5rem 1rem;
    }

    .quarter-title {
        font-size: 1.5rem;
    }

    .quarter-subtitle {
        font-size: 0.875rem;
    }
}

/* Guinness Section */
.guinness-section {
    border: 2px solid var(--gold);
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1) 0%, var(--bg-secondary) 100%);
}

.guinness-section .card-header {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15) 0%, rgba(251, 191, 36, 0.05) 100%);
}

.guinness-section .card-title {
    color: var(--gold);
}

.guinness-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    max-width: 500px;
    margin: 0 auto;
}

@media (max-width: 640px) {
    .guinness-grid {
        grid-template-columns: repeat(2, 1fr);
        max-width: 100%;
        gap: 0.75rem;
        padding: 0 0.5rem;
    }
}

.guinness-card {
    border-radius: 20px;
    aspect-ratio: 3 / 4;
    min-height: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.guinness-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
        transparent 0%,
        transparent 30%,
        rgba(0,0,0,0.4) 60%,
        rgba(0,0,0,0.85) 100%
    );
    z-index: 1;
}

.guinness-card-content {
    position: relative;
    z-index: 2;
    padding: 1.5rem;
    text-align: left;
}

.guinness-category {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 10;
    display: inline-block;
    font-size: 0.625rem;
    color: #fff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    padding: 0.25rem 0.625rem;
    border-radius: 4px;
}

.guinness-profile {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.guinness-profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.guinness-profile-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    opacity: 0.3;
}

.guinness-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 0.125rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

.guinness-team {
    font-size: 0.8125rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 0.75rem;
}

.guinness-record {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1;
}

.guinness-record-label {
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.6);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Premium Guinness Card - 프로필 사진이 있을 때 */
.guinness-card-premium {
    /* aspect-ratio 사용 */
}

.guinness-card-premium::before {
    background: linear-gradient(180deg,
        rgba(251,191,36,0.1) 0%,
        transparent 20%,
        transparent 40%,
        rgba(0,0,0,0.5) 70%,
        rgba(0,0,0,0.9) 100%
    );
}

.guinness-card-premium::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
    z-index: 3;
}

/* 왕관 */
.guinness-crown {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.75rem;
    z-index: 10;
    background: rgba(0,0,0,0.4);
    padding: 0.375rem;
    border-radius: 50%;
    backdrop-filter: blur(4px);
}

/* 글로우, 반짝이 효과 숨김 */
.guinness-glow,
.guinness-sparkles {
    display: none;
}

.guinness-card-premium .guinness-name {
    font-size: 1.75rem;
}

.guinness-card-premium .guinness-record {
    font-size: 1.75rem;
}

.guinness-card-premium .guinness-record-label {
    color: var(--gold);
}

@keyframes crownBounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(-3px); }
}

@keyframes profileGlow {
    0% {
        box-shadow:
            0 0 20px rgba(251, 191, 36, 0.5),
            0 0 40px rgba(251, 191, 36, 0.3),
            0 0 60px rgba(251, 191, 36, 0.2);
    }
    100% {
        box-shadow:
            0 0 30px rgba(251, 191, 36, 0.7),
            0 0 50px rgba(251, 191, 36, 0.5),
            0 0 70px rgba(251, 191, 36, 0.3);
    }
}

@keyframes shimmer {
    0% { background-position: -200% center; }
    100% { background-position: 200% center; }
}

@media (max-width: 480px) {
    .guinness-card {
        border-radius: 12px;
    }

    .guinness-card-content {
        padding: 0.75rem;
    }

    .guinness-category {
        font-size: 0.5rem;
        padding: 0.2rem 0.4rem;
        top: 0.5rem;
        left: 0.5rem;
    }

    .guinness-name {
        font-size: 0.875rem;
    }

    .guinness-team {
        font-size: 0.625rem;
    }

    .guinness-card-premium .guinness-name {
        font-size: 1rem;
    }

    .guinness-record {
        font-size: 0.875rem;
    }

    .guinness-card-premium .guinness-record {
        font-size: 1rem;
    }

    .guinness-record-label {
        font-size: 0.625rem;
    }

    .guinness-crown {
        font-size: 1rem;
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.2rem;
    }
}

/* All Records Modal */
.records-list {
    max-height: 400px;
    overflow-y: auto;
}

.record-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.record-item:last-child {
    border-bottom: none;
}

.record-rank {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.record-item:first-child .record-rank {
    background: var(--gold);
    color: var(--bg-primary);
}

.record-item:nth-child(2) .record-rank {
    background: var(--silver);
    color: var(--bg-primary);
}

.record-item:nth-child(3) .record-rank {
    background: var(--bronze);
    color: var(--bg-primary);
}

.record-profile {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-tertiary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.record-profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.record-info {
    flex: 1;
    min-width: 0;
}

.record-name {
    font-weight: 600;
    color: var(--text-primary);
}

.record-team {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.record-values {
    text-align: right;
}

.record-premium {
    font-weight: 700;
    color: var(--gold);
}

.record-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Growth Rate Colors */
.growth-positive {
    color: #ef4444 !important;
}

.growth-negative {
    color: #3b82f6 !important;
}

/* Quarter Selector */
.quarter-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.quarter-select {
    max-width: 120px;
    padding: 0.5rem 2rem 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Score Cell Dual Layout (value + score) */
.score-cell-dual {
    text-align: center;
    padding: 0.5rem 0.25rem;
}

.score-cell-dual .score-value {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.2;
}

.score-cell-dual .score-point {
    font-size: 0.7rem;
    color: var(--gold);
    font-weight: 500;
    margin-top: 2px;
    display: none;
}

/* Compact Table for 27-inch monitors */
.ranking-table-compact th,
.ranking-table-compact td {
    padding: 0.5rem 0.5rem;
}

.ranking-table-compact .agent-cell {
    gap: 0.5rem;
}

.ranking-table-compact .agent-profile {
    width: 32px;
    height: 32px;
}

.ranking-table-compact .agent-name {
    font-size: 0.875rem;
}

.ranking-table-compact .agent-team {
    font-size: 0.7rem;
}

.ranking-table-compact .rank-cell {
    font-size: 0.9375rem;
    padding: 0.5rem 0.25rem;
}

.ranking-table-compact .score-highlight {
    font-size: 1rem;
    font-weight: 700;
}

/* 컬럼 그룹 구분선 (조기가동+월납 | 건수+3W) */
.ranking-table th:nth-child(2),
.ranking-table td:nth-child(2) {
    border-right: 2px solid var(--border-color);
}

.ranking-table th:nth-child(4),
.ranking-table td:nth-child(4) {
    border-right: 2px solid var(--border-color);
}

.ranking-table th:nth-child(6),
.ranking-table td:nth-child(6) {
    border-right: 2px solid var(--border-color);
}

/* Tab Content */
.tab-content {
    display: block;
}

.tab-content.hidden {
    display: none;
}

/* Attendance Grid */
.attendance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.attendance-card {
    background: var(--bg-tertiary);
    border-radius: 0.75rem;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 2px solid var(--border-color);
    transition: all 0.2s ease;
    cursor: pointer;
}

.attendance-card:hover {
    border-color: var(--gold);
}

.attendance-card.checked {
    background: rgba(34, 197, 94, 0.15);
    border-color: var(--success);
}

.attendance-card.absent {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--error);
}

.attendance-checkbox {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.attendance-card.checked .attendance-checkbox {
    background: var(--success);
    border-color: var(--success);
}

.attendance-card.checked .attendance-checkbox::after {
    content: '✓';
    color: white;
    font-weight: bold;
    font-size: 0.875rem;
}

.attendance-card.absent .attendance-checkbox {
    background: var(--error);
    border-color: var(--error);
}

.attendance-card.absent .attendance-checkbox::after {
    content: '✕';
    color: white;
    font-weight: bold;
    font-size: 0.875rem;
}

.attendance-profile {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--bg-secondary);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attendance-profile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attendance-info {
    flex: 1;
    min-width: 0;
}

.attendance-name {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attendance-team {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.attendance-status {
    display: flex;
    gap: 0.5rem;
}

.attendance-btn {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.attendance-btn.present {
    background: var(--success);
    color: white;
}

.attendance-btn.absent {
    background: var(--error);
    color: white;
}

.attendance-btn.inactive {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

@media (max-width: 640px) {
    .attendance-grid {
        grid-template-columns: 1fr;
    }
}

/* Quick Navigation */
.quick-nav {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.quick-nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 2rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-nav-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--gold);
}

.quick-nav-btn.active {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: var(--bg-primary);
    border-color: var(--gold);
}

.quick-nav-btn span {
    font-size: 1rem;
}

/* Floating Navigation */
.floating-nav {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 100;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.floating-nav.visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.floating-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dark) 100%);
    color: #ffffff;
    border: none;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(217, 119, 6, 0.3);
    transition: all 0.2s ease;
}

.floating-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(217, 119, 6, 0.4);
}

.floating-btn-top {
    background: var(--bg-secondary);
    color: var(--text-primary);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    padding: 0.75rem;
    border: 1px solid var(--border-color);
}

.floating-btn-top:hover {
    background: var(--bg-tertiary);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    .quick-nav {
        gap: 0.5rem;
    }

    .quick-nav-btn {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }

    .floating-nav {
        bottom: 1rem;
        right: 1rem;
    }

    .floating-btn {
        padding: 0.625rem 0.875rem;
        font-size: 0.8125rem;
    }

    .floating-btn span {
        display: none;
    }
}

/* 근태 그리드 레이아웃 */
.attendance-grid-layout {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

@media (max-width: 1024px) {
    .attendance-grid-layout {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .attendance-grid-layout {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .attendance-grid-layout {
        grid-template-columns: 1fr;
    }
}

/* 목표 달성 표시 */
.ranking-table tr.achieved {
    background: linear-gradient(90deg, rgba(251, 191, 36, 0.1) 0%, transparent 100%);
}

.ranking-table tr.achieved td:first-child {
    border-left: 3px solid var(--gold);
}

.badge-gold {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
    color: #fff;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-weight: 600;
    font-size: 0.75rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    animation: achievedPulse 2s ease-in-out infinite;
}

@keyframes achievedPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4);
    }
    50% {
        box-shadow: 0 0 8px 2px rgba(251, 191, 36, 0.6);
    }
}

/* 명예의 전당 달성예정 카드 */
.fame-card-pending {
    opacity: 0.7;
    background: var(--bg-tertiary);
    border: 1px dashed var(--border-color);
}

.fame-card-pending .fame-profile-placeholder {
    font-size: 2rem;
}

/* 달성예정 배지 */
.pending-badge {
    display: inline-block;
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
    color: #fff;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* 남은 점수 배지 */
.badge-remaining {
    background: linear-gradient(135deg, #64748b 0%, #475569 100%);
    color: #fff;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-weight: 500;
    font-size: 0.7rem;
    white-space: nowrap;
}
