/* ---------- CSS Variables & Theming (Light B2B Enterprise) ---------- */
:root {
    /* Color Palette */
    --bg-base: #F4F6F8; /* Soft light background for the app body */
    --bg-main: #FFFFFF; /* White background for sidebar and main elements */
    --bg-panel: #FFFFFF; /* Solid white for UI panels/cards */
    --bg-glass-hover: rgba(0, 0, 0, 0.03); /* Subtle hover effect */
    
    --text-main: #333333; /* Dark text for readability */
    --text-muted: #525149; /* NAUS Gray for secondary text/labels */
    
    /* Accents */
    --accent-blue: #005DAA; /* NAUS Main Blue */
    --accent-blue-dim: rgba(0, 93, 170, 0.1);
    --accent-blue-glow: rgba(0, 93, 170, 0.2);
    
    --accent-green: #10b981;
    --accent-green-dim: rgba(16, 185, 129, 0.15);
    
    --accent-amber: #B1A699; /* NAUS Gold */
    --accent-amber-dim: rgba(177, 166, 153, 0.15);
    
    --accent-crimson: #ef4444;
    --accent-crimson-dim: rgba(239, 68, 68, 0.15);
    
    --accent-purple: #8b5cf6;
    --accent-purple-dim: rgba(139, 92, 246, 0.15);

    /* UI Structural Variables */
    --border-light: #E2E8F0; /* Light gray borders for panels and tables */
    --border-focus: rgba(0, 93, 170, 0.5);
    
    --panel-radius: 16px;
    --btn-radius: 8px;
    --input-radius: 10px;
    
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --sidebar-width: 280px;
    
    /* Shadows */
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.06);
}

/* ---------- Reset & Typography ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    overflow: hidden; /* SPA Feel */
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar - Light Theme */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ---------- Layout ---------- */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-main);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0,0,0,0.02);
    transition: width var(--transition-smooth);
}

.sidebar.collapsed {
    width: 80px;
}
.sidebar.collapsed .brand-logo {
    display: none;
}
.sidebar.collapsed .nav-section-title {
    display: none;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}
.sidebar.collapsed .nav-item span {
    display: none;
}
.sidebar.collapsed .user-info {
    display: none;
}
.sidebar.collapsed .sidebar-brand {
    padding: 0;
    justify-content: center;
}
.sidebar.collapsed #btn-sidebar-toggle {
    margin: 0 auto !important;
}
.sidebar.collapsed .sidebar-footer {
    display: flex;
    justify-content: center;
    padding: 20px 0;
}
.sidebar.collapsed .avatar {
    margin: 0 auto;
}

.sidebar-brand {
    height: 80px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-brand i {
    color: var(--accent-blue);
    font-size: 1.8rem;
}

.sidebar-brand .brand-subtitle {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    display: block;
    margin-top: 2px;
}

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

.nav-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 16px;
    padding-left: 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--btn-radius);
    margin-bottom: 4px;
    font-weight: 600;
    transition: var(--transition-fast);
    position: relative;
}

.nav-item i {
    font-size: 1.25rem;
    transition: var(--transition-fast);
}

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

.nav-item.active {
    color: var(--accent-blue);
    background: var(--accent-blue-dim);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 60%;
    width: 4px;
    background: var(--accent-blue);
    border-radius: 0 4px 4px 0;
}

.nav-item.active i {
    color: var(--accent-blue);
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-light);
    background-color: var(--bg-main);
}

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

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-blue-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-blue);
    font-size: 1.2rem;
}

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

.user-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---------- Main Content & Topbar ---------- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.topbar {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 10px rgba(0,0,0,0.015);
}

.search-bar {
    position: relative;
    width: 100%;
    max-width: 400px;
    min-width: 200px;
}

.search-bar i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.2rem;
}

.search-bar input {
    width: 100%;
    height: 44px;
    box-sizing: border-box;
    background: var(--bg-base);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 10px 16px 10px 44px;
    border-radius: 30px;
    outline: none;
    transition: var(--transition-fast);
    font-size: 0.9rem;
    font-weight: 500;
}

.search-bar input::placeholder {
    color: #94a3b8;
}

.search-bar input:focus {
    border-color: var(--accent-blue);
    background: #ffffff;
    box-shadow: 0 0 0 3px var(--accent-blue-dim);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 24px;
}

.lang-select {
    background: var(--bg-base);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    transition: var(--transition-fast);
}

.lang-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 2px var(--accent-blue-dim);
}

.clock {
    font-family: 'Inter', monospace;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent-blue);
    background: var(--accent-blue-dim);
    padding: 6px 14px;
    border-radius: 20px;
    letter-spacing: 0.5px;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    position: relative;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.icon-btn:hover {
    color: var(--accent-blue);
    background: var(--bg-base);
}

.notification-btn .badge {
    position: absolute;
    top: 2px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: var(--accent-crimson);
    color: #ffffff;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-main);
}

/* ---------- View Sections & Headers ---------- */
.view-section {
    padding: 24px 40px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    min-height: calc(100vh - 80px);
    display: none;
    flex-direction: column;
}

/* 주요 데이터 패널이 화면 하단 끝까지 꽉 차도록 확장 */
.view-section > .ui-panel {
    flex: 1 0 auto;
}

.page-header {
    display: none !important;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    color: var(--text-main);
}

.page-header .subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

/* ---------- Panels (Clean Light UI) ---------- */
.ui-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--panel-radius);
    box-shadow: var(--shadow-soft);
    padding: 24px;
    position: relative;
    overflow: visible;
    transition: var(--transition-smooth);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.panel-desc {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 4px;
}

/* Border Accent Modifiers */
.border-accent-blue { border-top: 4px solid var(--accent-blue); }
.border-accent-green { border-top: 4px solid var(--accent-green); }
.border-accent-amber { border-top: 4px solid var(--accent-amber); }
.border-accent-crimson { border-top: 4px solid var(--accent-crimson); }

/* ---------- KPI Grid & Cards ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.kpi-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.kpi-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.bg-blue-dim { background: var(--accent-blue-dim); color: var(--accent-blue); }
.bg-green-dim { background: var(--accent-green-dim); color: var(--accent-green); }
.bg-amber-dim { background: var(--accent-amber-dim); color: #9A8D7E; /* Slightly darker gold for contrast */ }
.bg-crimson-dim { background: var(--accent-crimson-dim); color: var(--accent-crimson); }

.kpi-value {
    font-size: 2.2rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 12px;
    color: var(--text-main);
}

.kpi-value .unit {
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 600;
}

.kpi-trend {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.kpi-trend.positive { color: var(--accent-green); }
.kpi-trend.warning { color: #9A8D7E; } /* Adjusted NAUS Gold */
.kpi-trend.negative { color: var(--accent-crimson); }

/* Utility Text Colors */
.text-crimson { color: var(--accent-crimson) !important; }
.text-amber { color: #9A8D7E !important; }
.text-green { color: var(--accent-green) !important; }
.text-blue { color: var(--accent-blue) !important; }

/* ---------- Layout Grids ---------- */
.content-grid-2col {
    display: grid;
    grid-template-columns: 3fr 2fr;
    gap: 24px;
}

/* ---------- Data Tables ---------- */
.table-responsive {
    overflow-x: auto;
    width: 100%;
}

.data-table {
    width: 100%;
    min-width: 900px; /* Force table to maintain PC layout and trigger horizontal scroll */
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    text-align: left;
    padding: 14px 16px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-light);
    font-weight: 700;
    white-space: nowrap;
}

.data-table td {
    padding: 16px;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text-main);
    font-weight: 500;
    white-space: nowrap;
}

.data-table tr {
    transition: var(--transition-fast);
}

.data-table tr:hover td {
    background: #F8FAFC;
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.status-active {
    background: var(--accent-green-dim);
    color: #0b9c6a; /* Darker green for readibility on light bg */
}

.status-warning {
    background: var(--accent-amber-dim);
    color: #9A8D7E; /* NAUS Gold for text */
}

.status-error {
    background: var(--accent-crimson-dim);
    color: #dc2626; /* Darker red for readibility */
}

/* Progress Bars */
.progress-bar-container {
    width: 100%;
    height: 8px;
    background: var(--bg-base);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 4px;
}

.progress-bar {
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s ease-in-out;
}

.fill-green { background: var(--accent-green); }
.fill-amber { background: var(--accent-amber); }
.fill-crimson { background: var(--accent-crimson); }

/* ---------- Buttons & Forms ---------- */
.btn-primary, .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--btn-radius);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition-fast);
    font-family: inherit;
}

.btn-primary {
    background: var(--accent-blue);
    color: #fff;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 93, 170, 0.2);
}

.btn-primary:hover {
    background: #004b87; /* Darker NAUS Blue */
    box-shadow: 0 6px 14px rgba(0, 93, 170, 0.3);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: var(--accent-blue);
    border: 1px solid var(--accent-blue);
}

.btn-secondary:hover {
    background: var(--accent-blue-dim);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.btn-block {
    width: 100%;
}

/* Modern Form Elements */
.modern-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-panel {
    background: #F8FAFC;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    margin-bottom: 24px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.form-group input, .form-group select {
    width: 100%;
    background: var(--bg-main);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    padding: 12px 14px;
    border-radius: var(--input-radius);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    outline: none;
    transition: var(--transition-fast);
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-dim);
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-with-icon i {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    font-size: 1.2rem;
}

.input-with-icon input {
    padding-left: 44px;
}

.form-grid-3col {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.form-section-title {
    font-size: 0.95rem;
    color: var(--accent-blue);
    font-weight: 700;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.radio-group {
    display: flex;
    gap: 16px;
    align-items: center;
    height: 44px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--text-main);
    font-weight: 500;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-blue);
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.input-with-button input {
    flex: 1;
}

.input-with-button .btn-icon {
    background: var(--bg-base);
    border: 1px solid var(--border-light);
    border-radius: var(--btn-radius);
    width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.input-with-button .btn-icon:hover {
    background: var(--accent-blue-dim);
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}

/* ---------- Specific Modules (WASM Panel) ---------- */
.wasm-panel {
    border: 1px solid var(--border-light);
    background: linear-gradient(145deg, #ffffff 0%, #F8FAFC 100%);
    position: relative;
}

.wasm-panel::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-amber));
}

.title-with-badge {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-wasm {
    background: linear-gradient(135deg, var(--accent-blue), #8b5cf6);
    color: #fff;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.2);
}

.result-display {
    margin-top: 24px;
    min-height: 100px;
}

.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: var(--bg-base);
    border-radius: 12px;
    border: 1px dashed #cbd5e1;
    color: var(--text-muted);
    gap: 12px;
    font-weight: 500;
}

.result-placeholder i {
    font-size: 2rem;
    color: #94a3b8;
}

.simulation-results {
    padding: 20px;
    border-radius: 12px;
    background: #F8FAFC;
    border: 1px solid var(--accent-blue-dim);
    box-shadow: var(--shadow-soft);
}

/* ---------- Modal (Settings) ---------- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 99999; /* 사이드바, 탑바를 넘어 무조건 최상단 전체화면을 덮도록 보장 */
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: var(--bg-main);
    width: 90%;
    /* max-width는 각 HTML 모달 인라인 스타일을 따름 */
    height: 90dvh !important; /* 모바일 브라우저 주소창(UI) 잘림 방지 */
    max-height: 90dvh !important;
    border-radius: var(--panel-radius);
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    overflow: hidden !important; /* 바깥 창 스크롤 차단, 내부만 스크롤되도록 강제 */
    display: flex;
    flex-direction: column;
}
.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* 헤더 영역 상단 고정 (찌그러짐 방지) */
}
.modal-header h2 { font-size: 1.25rem; font-weight: 700; color: var(--text-main); margin: 0; }
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-base);
    flex-shrink: 0;
}
.tab-btn {
    flex: 1;
    padding: 14px;
    border: none;
    background: none;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition-fast);
}
.tab-btn:hover { background: rgba(0,0,0,0.02); }
.tab-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
    background: var(--bg-main);
}
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1; /* 남은 가용 공간을 차지하며 스크롤 활성화 */
    min-height: auto;
    max-height: none; /* 기존 50vh 답답한 사이즈 제약 해제 */
    display: flex;
    flex-direction: column;
}
/* 모달 내 폼이 전체 높이를 사용하도록 하여 푸터 하단 고정 */
.modal-body form {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    background: var(--bg-base);
    margin: auto -24px -24px -24px !important; 
    position: sticky;
    bottom: -24px; 
    z-index: 10;
    flex-shrink: 0; /* 창 높이 압박 시 하단 버튼 영역이 찌그러지거나 잘리는 현상 방지 */
}

/* Menu Settings List UI */
.menu-settings-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--btn-radius);
    margin-bottom: 8px;
    transition: var(--transition-fast);
}
.menu-settings-item:hover {
    border-color: var(--accent-blue-dim);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.menu-controls { display: flex; flex-direction: column; gap: 2px; }
.menu-controls button {
    background: var(--bg-base);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 18px;
}
.menu-controls button:hover:not(:disabled) { background: var(--accent-blue-dim); color: var(--accent-blue); border-color: var(--accent-blue); }
.menu-settings-item i[class*="bx-"] { color: var(--text-muted); font-size: 1.2rem; }
.menu-settings-item input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    outline: none;
    font-size: 0.9rem;
}
.menu-settings-item input[type="text"]:focus { border-color: var(--accent-blue); }
.menu-settings-item input[type="checkbox"] {
    width: 18px; height: 18px; accent-color: var(--accent-blue); cursor: pointer;
}

/* ---------- Button Groups & Calendar ---------- */
.btn-group {
    display: flex;
    border: 1px solid var(--border-light);
    border-radius: var(--btn-radius);
    overflow: hidden;
}
.btn-group button {
    background: var(--bg-main);
    border: none;
    padding: 6px 14px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    border-right: 1px solid var(--border-light);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-group button:last-child { border-right: none; }
.btn-group button:hover { background: var(--bg-base); }
.btn-group button.active { background: var(--accent-blue-dim); color: var(--accent-blue); }

.calendar-header-day {
    padding: 10px;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    background: var(--border-light);
    gap: 1px;
}
.calendar-day {
    background: #fff;
    min-height: 120px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: var(--transition-fast);
}
.calendar-day:hover { background: #F8FAFC; }
.calendar-day.empty { background: #fdfdfd; }
.calendar-date {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.calendar-event {
    background: var(--accent-blue-dim);
    border-left: 3px solid var(--accent-blue);
    padding: 4px 6px;
    font-size: 0.75rem;
    border-radius: 4px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.calendar-sidebar-list.collapsed {
    width: 0 !important;
    border-right: none !important;
}

.calendar-mini-card {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    font-size: 0.85rem;
    white-space: normal;
}

.calendar-mini-card .mc-title {
    font-weight: 700;
    color: var(--accent-blue);
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
}

.calendar-mini-card .mc-info {
    color: var(--text-muted);
    margin-bottom: 2px;
}

/* Multi-select Dropdown CSS */
.cal-multi-select { position: relative; display: inline-block; min-width: 160px; font-size: 0.85rem; }
.cal-multi-select-header { 
    background: var(--bg-main); border: 1px solid var(--border-light); border-radius: var(--btn-radius); 
    padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; 
    cursor: pointer; color: var(--text-main); font-weight: 500;
}
.cal-multi-select-dropdown {
    position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-main);
    border: 1px solid var(--border-light); border-radius: var(--btn-radius); margin-top: 4px;
    box-shadow: var(--shadow-hover); max-height: 200px; overflow-y: auto; z-index: 200;
    display: none; flex-direction: column; padding: 4px;
}
.cal-multi-select.open .cal-multi-select-dropdown { display: flex; }
.cal-multi-select-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 8px;
    cursor: pointer; transition: background 0.2s; border-radius: 4px; color: var(--text-main);
}
.cal-multi-select-item:hover { background: var(--bg-base); }
.cal-multi-select-item input { pointer-events: none; }

/* Calendar Time Grid (Week/Day) */
.calendar-time-grid {
    display: flex;
    min-width: 600px;
}
.calendar-time-axis {
    width: 60px;
    flex-shrink: 0;
    border-right: 1px solid var(--border-light);
    background: var(--bg-base);
}
.calendar-time-label {
    height: 60px; /* 1 hour = 60px */
    position: relative;
    border-bottom: 1px solid transparent;
}
.calendar-time-label span {
    position: absolute;
    top: -8px;
    right: 8px;
    font-size: 0.7rem;
    color: var(--text-muted);
}
.calendar-day-columns {
    display: flex;
    flex: 1;
}
.calendar-day-col {
    flex: 1;
    border-right: 1px solid var(--border-light);
    position: relative;
    background: repeating-linear-gradient(to bottom, transparent, transparent 59px, var(--border-light) 60px);
}
.calendar-day-col:last-child {
    border-right: none;
}
.calendar-event-block {
    position: absolute;
    left: 2px;
    right: 2px;
    background: var(--accent-blue-dim);
    border-left: 4px solid var(--accent-blue);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.75rem;
    color: var(--text-main);
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10;
    cursor: pointer;
    transition: var(--transition-fast);
}
.calendar-event-block:hover {
    z-index: 20;
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

/* Schedule Tooltip */
.calendar-event-tooltip {
    display: none;
    position: absolute;
    z-index: 100;
    left: calc(100% + 8px);
    top: -4px;
    width: 260px;
    padding: 14px;
    border-radius: 8px;
    background: #1e293b;
    color: #f8fafc;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    font-size: 0.8rem;
    line-height: 1.5;
    text-align: left;
    pointer-events: none;
}
.calendar-event-block:hover .calendar-event-tooltip,
.calendar-event:hover .calendar-event-tooltip {
    display: block;
}
.calendar-event-tooltip strong {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 6px;
}
.calendar-event-tooltip dl {
    display: grid;
    grid-template-columns: 75px 1fr;
    gap: 4px 8px;
    margin: 0;
}
.calendar-event-tooltip dt { color: #94a3b8; }
.calendar-event-tooltip dd { margin: 0; color: #fff; font-weight: 600; word-break: break-word; }
.calendar-event-tooltip dd.note-text { color: #fbbf24; }

/* Note Highlight */
.calendar-event-block.has-note {
    border-right: 4px solid var(--accent-amber) !important;
}

@media (max-width: 768px) {
    .calendar-event-tooltip {
        left: auto;
        right: 0;
        top: calc(100% + 4px);
    }
}

.calendar-event-block.downtime-block {
    background: repeating-linear-gradient(45deg, rgba(148,163,184,0.1), rgba(148,163,184,0.1) 8px, rgba(148,163,184,0.25) 8px, rgba(148,163,184,0.25) 16px) !important;
    border-left: 6px solid var(--text-muted) !important;
    color: var(--text-main) !important;
}
.downtime-template {
    background: #f8fafc;
    border: 1px dashed var(--text-muted) !important;
    border-left: 4px solid var(--text-muted) !important;
}
.btn-remove-schedule-inline:hover {
    color: var(--accent-crimson) !important;
}

/* ---------- Two Week Team Schedule Table ---------- */
.two-week-table {
    width: 100%;
    min-width: 1200px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    font-size: 0.85rem;
}

.two-week-table th, .two-week-table td {
    border-bottom: 1px solid var(--border-light);
    border-right: 1px solid var(--border-light);
    padding: 6px;
    vertical-align: top;
    background: var(--bg-main);
    color: var(--text-main);
}

.two-week-table th:first-child, .two-week-table td:first-child {
    border-left: 1px solid var(--border-light);
}

.two-week-table thead th {
    position: sticky;
    top: 0;
    background: var(--bg-base);
    z-index: 20;
    text-align: center;
    color: var(--text-muted);
    font-weight: 700;
}

.two-week-table thead th.tw-machine {
    z-index: 21;
    width: 100px;
    background: var(--bg-base);
}

.tw-day { font-weight: 800; font-size: 0.9rem; color: var(--text-main); }
.tw-weekday { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.tw-shift {
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 6px;
    margin-bottom: 6px;
    background: #F8FAFC;
}
.tw-shift:last-child { margin-bottom: 0; }
.tw-shift-title { font-size: 0.75rem; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; }
.tw-empty { color: var(--text-muted); text-align: center; padding: 10px 0; font-style: italic; }

.tw-item {
    background: #fff;
    border: 1px solid var(--border-light);
    border-left: 3px solid var(--accent-blue);
    border-radius: 6px;
    padding: 6px;
    margin-bottom: 6px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    position: relative;
}
.tw-item:last-child { margin-bottom: 0; }
.tw-item:hover .tw-tooltip {
    display: block;
}

.tw-tooltip {
    display: none;
    position: absolute;
    z-index: 999;
    left: calc(100% + 8px);
    top: -4px;
    width: 260px;
    padding: 14px;
    border-radius: 8px;
    background: #1e293b;
    color: #f8fafc;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    font-size: 0.8rem;
    line-height: 1.5;
    text-align: left;
    pointer-events: none;
}
.tw-tooltip strong {
    display: block;
    margin-bottom: 8px;
    font-size: 0.95rem;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 6px;
}
.tw-tooltip dl {
    display: grid;
    grid-template-columns: 70px 1fr;
    gap: 4px 8px;
    margin: 0;
}
.tw-tooltip dt { color: #94a3b8; }
.tw-tooltip dd { margin: 0; color: #fff; font-weight: 600; word-break: break-word; }
@media (max-width: 768px) {
    .tw-tooltip {
        left: auto;
        right: 0;
        top: calc(100% + 4px);
    }
}
.tw-item.downtime { border-left-color: var(--accent-crimson); background: #fff3f3; }

.tw-item-name { font-weight: 700; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-item-spec { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tw-status-select {
    width: 100%;
    padding: 2px 4px;
    font-size: 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-light);
    outline: none;
    font-weight: 600;
}
.tw-status-select.status-대기 { color: var(--text-muted); }
.tw-status-select.status-가공중 { color: var(--accent-amber); background: var(--accent-amber-dim); border-color: transparent; }
.tw-status-select.status-가공완료 { color: var(--accent-green); background: var(--accent-green-dim); border-color: transparent; }

/* ---------- Table Controls & Pagination ---------- */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding: 0 4px;
    gap: 16px;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.table-controls .search-filter {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.table-controls .search-filter i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.table-controls .table-search-input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    border: 1px solid var(--border-light);
    border-radius: var(--btn-radius);
    background: var(--bg-base);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-fast);
}

.table-controls .table-search-input:focus {
    border-color: var(--accent-blue);
    background: #fff;
    box-shadow: 0 0 0 3px var(--accent-blue-dim);
}

.table-controls .page-size {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

.table-controls .table-page-size {
    padding: 6px 12px;
    border: 1px solid var(--border-light);
    border-radius: var(--btn-radius);
    background: var(--bg-main);
    outline: none;
    cursor: pointer;
    font-size: 0.85rem;
}

.table-pagination {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    padding: 0 4px;
}

.table-pagination .page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    border: 1px solid var(--border-light);
    background: var(--bg-main);
    color: var(--text-muted);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
}

.table-pagination .page-btn:hover:not(:disabled) {
    background: var(--bg-base);
    color: var(--accent-blue);
    border-color: var(--accent-blue-dim);
}

.table-pagination .page-btn.active {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}

.table-pagination .page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--bg-base);
}

/* ---------- Animations ---------- */
@keyframes fadeInSlideUp {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: none; /* 애니메이션 종료 시 fixed 컨텍스트 해제 -> 오버레이가 전체 화면을 덮음 */
    }
}

@keyframes ai-preview-pulse {
    0% { opacity: 0.8; box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4); }
    50% { opacity: 1; box-shadow: 0 0 0 4px rgba(139, 92, 246, 0); }
    100% { opacity: 0.8; box-shadow: 0 0 0 0 rgba(139, 92, 246, 0); }
}

.animation-fade-in {
    animation: fadeInSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ---------- Responsive Design ---------- */
@media (max-width: 1024px) {
    .content-grid-2col {
        grid-template-columns: 1fr;
    }
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90; /* Below sidebar (100) */
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.show {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    /* 모바일 네이티브 스크롤 활성화 (Safari 하단 스크롤 막힘 버그 원천 차단) */
    body {
        overflow-y: auto !important;
    }
    .app-container {
        height: auto !important;
        min-height: 100dvh;
    }
    .main-content {
        overflow-y: visible !important;
        height: auto !important;
    }

    /* 이중 스크롤 및 하단 빈 공간 방지 (앱 전체 화면 꽉 차게 렌더링) */
    #view-calendar {
        padding: 0 !important;
    }
    #view-calendar .page-header {
        padding: 20px 20px 0 20px;
        margin-bottom: 16px;
    }
    #view-calendar .ui-panel {
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-bottom: none;
    }
    .calendar-split-layout {
        min-height: auto !important;
        height: auto !important;
    }
    /* 내부 스크롤 해제 -> 앱 메인 스크롤로 통합하여 이중 스크롤 방지 */
    .calendar-main-area, .calendar-grid-wrapper, #calendar-days-grid {
        overflow: visible !important;
    }
    #calendar-days-grid {
        height: auto !important;
    }

    /* 모바일 캘린더 레이아웃 최적화 */
    .calendar-sidebar-list {
        position: absolute !important;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px !important;
        z-index: 50;
        box-shadow: 2px 0 12px rgba(0,0,0,0.15) !important;
        transform: translateX(0);
        transition: transform 0.3s ease, width 0s !important;
    }
    .calendar-sidebar-list.collapsed {
        transform: translateX(-100%);
        width: 280px !important;
    }
    
    #view-calendar .panel-header {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center !important;
        gap: 16px;
        padding: 10px 20px 16px 20px !important; /* 상하 패딩 추가하여 버튼 짤림 방지 */
        margin: 0 -20px; /* 좌우 끝까지 스와이프 되도록 마진 상쇄 */
        height: auto;
        overflow-x: auto;
        white-space: nowrap;
    }
    #view-calendar .panel-header::-webkit-scrollbar {
        display: none; /* 모바일에서 미관상 스크롤바 숨김 */
    }
    #view-calendar .panel-header > div:first-child,
    #view-calendar .panel-header > div:last-child {
        width: auto;
        flex-shrink: 0;
    }
    
    .calendar-filters {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        padding: 4px 0 12px 0 !important; /* 드롭다운/테두리 위아래 잘림 방지 */
    }
    .calendar-filters::-webkit-scrollbar {
        display: none;
    }
    
    .calendar-toolbar {
        flex-wrap: nowrap;
        gap: 16px;
        justify-content: flex-start !important;
        overflow-x: auto;
        padding: 4px 0 12px 0 !important; /* 버튼 테두리 및 그림자 상단 잘림 방지 */
    }
    .calendar-toolbar::-webkit-scrollbar {
        display: none;
    }
    .calendar-toolbar > div {
        flex-shrink: 0;
    }
    #calendar-month-display {
        width: auto;
        order: 0;
        margin-bottom: 0 !important;
        white-space: nowrap;
        flex-shrink: 0;
    }
    
    .cal-multi-select {
        flex: 0 0 auto;
        min-width: 130px !important;
    }

    /* 버튼 텍스트 줄바꿈 강제 방지 */
    .btn-primary, .btn-secondary, .btn-group button {
        white-space: nowrap;
    }
    
    .calendar-grid-wrapper {
        overflow-x: auto !important;
    }

    .modal-content {
        width: 95%;
        height: 95dvh !important;
        max-height: 95dvh !important;
    }
    .mobile-menu-toggle {
        display: flex !important;
    }

    #btn-sidebar-toggle {
        display: none !important;
    }

    .sidebar {
        width: 280px !important;
        position: fixed;
        top: 0; left: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
        box-shadow: none;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 2px 0 20px rgba(0,0,0,0.15);
    }

    .view-section {
        padding: 20px 16px;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    #topbar-page-info {
        display: none !important; /* 모바일 공간 부족으로 타이틀 숨김 */
    }

    .search-bar {
        width: 100%;
        max-width: none !important;
        margin-left: 0 !important;
    }
    
    .topbar-actions {
        gap: 12px;
    }
    
    .clock {
        display: none; /* Hide clock on very small screens to save space */
    }

    .form-row {
        flex-direction: column;
        gap: 16px;
    }
    
    .form-grid-3col {
        grid-template-columns: 1fr;
    }
}
```