:root {
    /* 🔥 밝은 SaaS 테마로 변경 */
    --bg-dark: #f5f7fb;
    --card-bg: #ffffff;

    --accent-cyan: #2f6fed;
    --accent-blue: #1e4ed8;

    --text-main: #111827;
    --text-dim: #6b7280;

    --border-color: #e5e7eb;

    /* AG Grid용 */
    --grid-viewport-rgb: rgb(255, 255, 255);
    --grid-row-rgb: rgb(255, 255, 255);
    --grid-header-rgb: rgb(249, 250, 251);
}

body { 
    overflow: hidden; 
    height: 100vh;

    background-color: var(--bg-dark); 
    color: var(--text-main);

    font-family: 'Noto Sans KR', sans-serif;
    margin: 0; 
    display: flex;
    overflow-x: hidden;
}

/* 🔥 상단 네비 */
.top-nav {
    position: fixed;
    top: 0;
    left: 220px;
    width: calc(100% - 220px);
    height: 89px;

    background: #ffffff;
    border-bottom: 1px solid var(--border-color);

    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 30px;

    z-index: 1000;
}

/* 메인 */
.main-content {
    margin-left: 220px;
    margin-top: 89px;
    width: calc(100% - 220px);

    padding: 10px;
    box-sizing: border-box;

    display: flex;
    flex-direction: column;
}

/* 헤더 */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 5px;
}

/* 🔥 검색 영역 */
.search-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);

    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;

    display: flex;
    gap: 20px;
    align-items: center;
}

/* 🔥 input */
.form-control {
    background-color: #ffffff !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-main) !important;
}

/* 🔥 버튼 */
.btn-search {
    background: #2f6fed;
    color: #ffffff;
    font-weight: 700;
    border: none;
    padding: 8px 25px;
    border-radius: 6px;
}

/* 타이틀 */
.main-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* breadcrumb */
.breadcrumb-text {
    font-size: 0.9rem;
    color: var(--text-dim);
}

.breadcrumb-text span {
    color: var(--text-dim);
    font-weight: 600;
}

/* 로고 */
.logo-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.logo-link:hover {
    color: inherit;
}

/* 🔥 푸터 */
.mes-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;

    height: 40px;
    background: #ffffff;

    color: #6b7280;
    font-size: 13px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 20px;
    border-top: 1px solid var(--border-color);

    z-index: 1000;
}

.mes-footer .footer-left {
    color: #9ca3af;
}

.mes-footer .footer-center {
    color: #6b7280;
}

.mes-footer .footer-right {
    color: #9ca3af;
}

.page-title {
    font-size: 16px;
    font-weight: 700;
    color:#6b7280;
    display: flex;
}

.page-sav-title {
    font-size: 16px;
    font-weight: 700;
    color: #2f6fed;
}

.page-comment {
    font-size:12px; 
    color:#6b7280;
}

.sep {
    margin: 0 6px;
    color: #9ca3af;
}

/* Reusable dashboard primitives */
.mes-filter-panel,
.mes-panel,
.mes-kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    /* border-radius: 12px; */
}

.mes-filter-panel {
    padding: 12px;
    display: grid;
    gap: 10px;
    align-items: end;
    justify-content: start;
}

.mes-filter-panel label {
    display: block;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.mes-kpi-grid {
    display: grid;
    gap: 10px;
}

.kpi-grid {
    margin-top: -18px;
}

.mes-kpi-card {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 7px;
}

.mes-kpi-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-dim);
}

.mes-kpi-value {
    font-size: 27px;
    font-weight: 800;
    color: var(--text-main);
    line-height: 1;
}

.mes-kpi-caption {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mes-panel {
    padding: 10px;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.mes-panel .ag-theme-alpine {
    flex: 1;
    min-height: 220px;
}

.mes-sub-title {
    font-size: 13px;
    font-weight: 900;
    color: var(--text-main);
}

.mes-sub-caption {
    font-size: 12px;
    color: var(--text-dim);
}

.mes-source-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 900;
}

.mes-source-production {
    background: #dbeafe;
    color: #1d4ed8;
}

.mes-source-good {
    background: #dcfce7;
    color: #15803d;
}

/* Common KPI/status primitives */
.mes-status-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.mes-status-kpi-card {
    position: relative;
    overflow: hidden;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 14px 16px;
}

.mes-status-kpi-card::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #64748b;
}

.mes-status-kpi-card.kpi-blue::before { background: #2563eb; }
.mes-status-kpi-card.kpi-green::before { background: #16a34a; }
.mes-status-kpi-card.kpi-red::before { background: #dc2626; }
.mes-status-kpi-card.kpi-yellow::before { background: #ca8a04; }
.mes-status-kpi-card.kpi-teal::before { background: #0f766e; }
.mes-status-kpi-card.kpi-purple::before { background: #7c3aed; }

.mes-status-legend {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    margin-left: 10px;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
}

.mes-status-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 0;
    background: transparent;
    padding: 0;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
}

.mes-status-legend-item.active {
    color: #0f172a;
    font-weight: 900;
}

.mes-status-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, .08);
    background: #fff;
}

.mes-status-legend-dot.status-gray { background: #f8fafc; }
.mes-status-legend-dot.status-blue { background: #eff6ff; }
.mes-status-legend-dot.status-green { background: #f0fdf4; }
.mes-status-legend-dot.status-yellow { background: #fffbeb; }
.mes-status-legend-dot.status-red { background: #fef2f2; }
.mes-status-legend-dot.status-purple { background: #f5f3ff; }

.ag-theme-alpine .ag-row.mes-row-status-gray .ag-cell { background-color: #fbfcfe !important; }
.ag-theme-alpine .ag-row.mes-row-status-blue .ag-cell { background-color: #f8fbff !important; }
.ag-theme-alpine .ag-row.mes-row-status-green .ag-cell { background-color: #f8fff9 !important; }
.ag-theme-alpine .ag-row.mes-row-status-yellow .ag-cell { background-color: #fffdf5 !important; }
.ag-theme-alpine .ag-row.mes-row-status-red .ag-cell { background-color: #fffafa !important; }
.ag-theme-alpine .ag-row.mes-row-status-purple .ag-cell { background-color: #fbfaff !important; }

/* Common split-grid layout */
.mes-split-layout {
    display: flex;
    gap: 8px;
    min-height: 0;
    flex: 1;
}

.mes-split-pane {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.mes-split-pane > .ag-theme-alpine {
    flex: 1;
    min-height: 0;
}

/* Common report page components */
.report-page {
    gap: 10px;
    min-height: 0;
    height: calc(100vh - 89px);
}

.report-sheet {
    width: 100%;
    flex: 1;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 17px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    margin-top: -22px;
}

.sheet-header {
    border-bottom: 2px solid #111827;
    padding-bottom: 8px;
}

.sheet-title {
    font-size: 20px;
    font-weight: 900;
    color: #111827;
}

.sheet-meta {
    margin-top: 4px;
    font-size: 12px;
    color: #64748b;
}

.report-kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.report-kpi-card {
    border: 1px solid #cbd5e1;
    border-left: 4px solid #64748b;
    border-radius: 8px;
    padding: 9px 11px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.report-kpi-label {
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
}

.report-kpi-value {
    margin-top: 5px;
    font-size: 24px;
    font-weight: 900;
    color: #111827;
    line-height: 1;
}

.report-kpi-caption {
    margin-top: 6px;
    font-size: 10px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.report-chart-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 10px;
    flex: 1;
    min-height: 0;
}

.report-chart-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.report-chart-card.status-card {
    grid-row: auto;
}

.chart-title {
    font-size: 13px;
    font-weight: 900;
    color: #111827;
}

.chart-subtitle {
    margin-top: 2px;
    font-size: 10px;
    color: #64748b;
}

.chart-canvas-wrap {
    flex: 1;
    min-height: 0;
    margin-top: 8px;
    position: relative;
}

.chart-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.report-doughnut-box {
    display: grid;
    grid-template-columns: 128px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    flex: 1;
    min-height: 0;
    margin-top: 8px;
}

.report-chart-legend-vertical {
    display: grid;
    gap: 6px;
    align-content: center;
    min-width: 0;
}

.report-chart-legend-item {
    display: grid;
    grid-template-columns: 10px minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px;
    border: 0;
    background: transparent;
    padding: 2px 0;
    font-size: 11px;
    font-weight: 800;
    color: #111827;
    text-align: left;
}

.report-chart-legend-item.is-hidden {
    opacity: .38;
}

.report-chart-legend-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.report-chart-legend-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.report-chart-legend-value {
    color: #334155;
    font-weight: 900;
}

.report-doughnut-canvas-wrap {
    position: relative;
    height: 100%;
    min-height: 0;
}

.report-doughnut-canvas-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

.empty-chart {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 12px;
}

.board-countdown {
    display: none;
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 3000;
    align-items: center;
    gap: 5px;
    padding: 7px 11px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: rgba(255, 255, 255, .92);
    box-shadow: 0 10px 30px rgba(15, 23, 42, .12);
    color: #334155;
    font-size: 12px;
    font-weight: 800;
}

#boardReloadCountdown {
    min-width: 20px;
    color: #0f172a;
    text-align: right;
}

body.report-board-mode,
body.defect-board-mode {
    overflow: hidden;
}

body.report-board-mode .sidebar,
body.report-board-mode .top-nav,
body.report-board-mode .mes-footer,
body.report-board-mode .navbar,
body.report-board-mode .nav-wrap,
body.report-board-mode footer,
body.report-board-mode .footer,
body.defect-board-mode .sidebar,
body.defect-board-mode .top-nav,
body.defect-board-mode .mes-footer,
body.defect-board-mode .navbar,
body.defect-board-mode .nav-wrap,
body.defect-board-mode footer,
body.defect-board-mode .footer {
    display: none !important;
}

body.report-board-mode .main-content,
body.defect-board-mode .main-content {
    width: 100vw !important;
    max-width: none !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.report-board-mode .report-page > .grid-header,
body.report-board-mode .report-page > .report-filter,
body.defect-board-mode .report-page > .grid-header,
body.defect-board-mode .report-page > .report-filter {
    display: none !important;
}

body.report-board-mode .report-sheet > .sheet-header,
body.defect-board-mode .report-sheet > .sheet-header {
    display: none !important;
}

body.report-board-mode .report-sheet,
body.defect-board-mode .report-sheet {
    width: calc(100vw - 100px) !important;
    height: calc(100vh - 100px) !important;
    flex: none !important;
    border: 0;
    border-radius: 0;
    padding: 0;
    margin: 50px !important;
}

body.report-board-mode .board-countdown,
body.defect-board-mode .board-countdown {
    display: flex;
}

@media (max-width: 1000px) {
    .report-filter,
    .report-kpi-grid,
    .report-chart-grid,
    .mes-status-kpi-grid {
        grid-template-columns: 1fr;
        grid-template-rows: none;
    }

    .report-sheet {
        width: 100%;
        aspect-ratio: auto;
    }
}
