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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #64748b;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --darker: #0f172a;
    --light: #f8fafc;
    --border: #e2e8f0;
    --sidebar-width: 260px;
    --header-height: 70px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--light);
    color: var(--dark);
    min-height: 100vh;
}

.hidden { display: none !important; }

/* ===== 로그인 화면 ===== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--darker) 0%, #1a1a2e 100%);
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 24px;
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.logo i {
    font-size: 2.5rem;
}

.login-subtitle {
    color: var(--secondary);
    margin-top: 8px;
    font-size: 0.95rem;
}

.login-tabs {
    display: flex;
    background: var(--light);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 24px;
}

.login-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.login-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.input-group {
    position: relative;
}

.input-group i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--secondary);
}

.input-group input {
    width: 100%;
    padding: 16px 16px 16px 48px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.2s;
    background: var(--light);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
}

.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99,102,241,0.3);
}

.login-footer {
    text-align: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    color: var(--secondary);
    font-size: 0.85rem;
}

/* ===== 메인 앱 ===== */
.main-app {
    display: flex;
    min-height: 100vh;
}

/* ===== 사이드바 ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--darker);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header .logo {
    justify-content: flex-start;
    color: white;
    font-size: 1.5rem;
}

.sidebar-header .logo i {
    font-size: 1.8rem;
    color: var(--primary);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    display: block;
    padding: 8px 24px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255,255,255,0.4);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background: rgba(99,102,241,0.2);
    color: white;
    border-left-color: var(--primary);
}

.nav-item i {
    width: 20px;
    font-size: 1.1rem;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
}

.btn-logout {
    padding: 10px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 8px;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239,68,68,0.2);
    color: var(--danger);
}

/* ===== 메인 콘텐츠 ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.content-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sidebar-toggle {
    display: none;
    padding: 8px;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--secondary);
    cursor: pointer;
}

.content-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.period-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--light);
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--secondary);
}

.period-badge i {
    color: var(--primary);
}

/* ===== 페이지 컨테이너 ===== */
.page-container {
    flex: 1;
    padding: 32px;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

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

/* ===== 통계 카드 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.blue { background: rgba(99,102,241,0.1); color: var(--primary); }
.stat-icon.orange { background: rgba(245,158,11,0.1); color: var(--warning); }
.stat-icon.green { background: rgba(34,197,94,0.1); color: var(--success); }
.stat-icon.purple { background: rgba(168,85,247,0.1); color: #a855f7; }

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--secondary);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
}

/* ===== 카드 ===== */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 24px;
}

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

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 i {
    color: var(--primary);
}

.card-body {
    padding: 24px;
}

.card-actions {
    display: flex;
    gap: 12px;
}

.search-input {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    width: 200px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== 대시보드 그리드 ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ===== 정산 요약 ===== */
.summary-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.summary-row:last-child {
    border-bottom: none;
}

.summary-row .label {
    color: var(--secondary);
    font-size: 0.95rem;
}

.summary-row .value {
    font-weight: 600;
    font-size: 1rem;
}

.summary-row .value.negative {
    color: var(--danger);
}

.total-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
}

.total-label {
    font-size: 0.95rem;
    opacity: 0.9;
}

.total-value {
    font-size: 1.8rem;
    font-weight: 700;
}

/* ===== 차트 ===== */
.chart-container {
    padding: 20px 0;
}

.chart-bar {
    margin-bottom: 20px;
}

.chart-bar-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.chart-bar-label span:first-child {
    color: var(--secondary);
}

.chart-bar-label span:last-child {
    font-weight: 600;
}

.chart-bar-track {
    height: 12px;
    background: var(--light);
    border-radius: 6px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s ease;
}

.chart-bar-fill.blue { background: linear-gradient(90deg, #6366f1, #818cf8); }
.chart-bar-fill.green { background: linear-gradient(90deg, #22c55e, #4ade80); }
.chart-bar-fill.orange { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.chart-bar-fill.red { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ===== 테이블 ===== */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.data-table th {
    background: var(--light);
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    text-align: center;
}

.data-table tbody tr {
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: var(--light);
}

.data-table .amount {
    text-align: center;
    font-family: 'SF Mono', Monaco, monospace;
}

.data-table .negative {
    color: var(--danger);
}

.data-table .badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-delivery { background: rgba(34,197,94,0.1); color: var(--success); }
.badge-manual { background: rgba(99,102,241,0.1); color: var(--primary); }

/* ===== 분실/파손 합계 ===== */
.loss-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 16px 20px;
    background: rgba(239,68,68,0.05);
    border-radius: 12px;
    border: 1px solid rgba(239,68,68,0.2);
}

.loss-total span:first-child {
    font-weight: 500;
    color: var(--secondary);
}

.loss-total-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--danger);
}

/* ===== 업로드 ===== */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(99,102,241,0.02);
}

.upload-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 16px;
}

.upload-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 0.9rem;
    color: var(--secondary);
}

.upload-progress {
    margin-top: 24px;
}

.progress-bar {
    height: 8px;
    background: var(--light);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-dark));
    border-radius: 4px;
    width: 0;
    transition: width 0.3s;
}

.progress-text {
    display: block;
    text-align: center;
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--secondary);
}

/* ===== 파일 목록 ===== */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--light);
    border-radius: 12px;
    transition: all 0.2s;
}

.file-item:hover {
    background: #e2e8f0;
}

.file-icon {
    width: 44px;
    height: 44px;
    background: rgba(34,197,94,0.1);
    color: var(--success);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.file-date {
    font-size: 0.85rem;
    color: var(--secondary);
}

.file-status {
    padding: 6px 12px;
    background: rgba(34,197,94,0.1);
    color: var(--success);
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.3;
}

/* ===== 편집 가능 테이블 ===== */
.editable-table input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    background: var(--light);
    transition: all 0.2s;
}

.editable-table input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.editable-table input::placeholder {
    color: #aaa;
}

.editable-table input.invalid {
    border-color: var(--danger);
    background: rgba(239,68,68,0.05);
}

.editable-table input.invalid:focus {
    box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

.editable-table td {
    padding: 8px 10px;
}

.address-input-wrap {
    display: flex;
    gap: 6px;
}

.address-input-wrap input {
    flex: 1;
    cursor: pointer;
}

.btn-address {
    padding: 8px 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-address:hover {
    background: var(--primary-dark);
}

.btn-save-all {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--success), #16a34a);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-save-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(34,197,94,0.3);
}

.btn-save-all:active {
    transform: translateY(0);
}

/* ===== 반응형 ===== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle {
        display: block;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .page-container {
        padding: 16px;
    }
    .content-header {
        padding: 0 16px;
    }
    .login-container {
        padding: 32px 24px;
    }
}
