﻿:root {
    /* Brand Colors Applied */
    --primary: #001C77;
    /* Navy */
    --primary-dark: #00124D;
    --success: #00C6C1;
    /* Teal */
    --orange: #F75C03;
    /* Orange */
    --purple: #7F27A4;
    /* Purple */
    --danger: #CE092F;
    /* Crimson Red */
    --bg: #f8fafc;
    --card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

* {
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    margin: 0;
    padding: 24px;
    line-height: 1.5;
    overflow-x: hidden;
}

@media (max-width: 768px) {
    body {
        padding: 12px;
    }
}

.container {
    max-width: 1600px;
    /* 기존 1700px에서 소폭 축소하여 좌우 여유 확보 */
    margin: 0 auto;
    width: 95%;
    /* 100% 대신 95%로 실질적인 사이드 여백 확보 */
    display: flex;
    flex-direction: column;
    gap: 24px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 24px 32px;
    border-radius: 20px;
    border: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    position: relative;
    z-index: 10;
}

@media (max-width: 768px) {
    header {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
    }
}

.header-logo-group {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 4px;
}

.logo-fallback {
    font-size: 26px;
    font-weight: 900;
    color: #000;
    letter-spacing: -0.05em;
}

.header-divider {
    width: 1.5px;
    height: 24px;
    background: var(--border);
}

.header-left h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 850;
    letter-spacing: -0.04em;
    color: var(--text-main);
}

.header-left p {
    margin: 2px 0 0;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

.control-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    background: white;
    color: #475569;
    outline: none;
}

.btn:hover {
    background: #f8fafc;
    transform: translateY(-1px);
    border-color: #cbd5e1;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-dark {
    background: #1e293b;
    color: white;
    border: none;
}

.btn-success {
    background: var(--success);
    color: white;
    border: none;
}

.btn-danger {
    background: var(--danger);
    color: white;
    border: none;
}

.btn-xs {
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 8px;
}

select,
.search-input {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    outline: none;
    background: white;
}

.search-input {
    width: 220px;
}

.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

@media (max-width: 1400px) {
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }
}

.kpi-card {
    background: white;
    padding: 24px;
    border-radius: 20px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.kpi-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-value-box {
    display: flex;
    align-items: baseline;
    gap: 5px;
}

.kpi-value {
    font-size: 30px;
    font-weight: 850;
    color: var(--text-main);
}

.kpi-unit {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 600;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 1.4fr 1.6fr;
    gap: 24px;
}

.dashboard-grid.heatmap-row {
    grid-template-columns: 7fr 3fr;
}

@media (max-width: 1600px) {
    .dashboard-grid.heatmap-row {
        grid-template-columns: 6.5fr 3.5fr;
        /* 중간 화면에서 비율 완화 */
    }
}

@media (max-width: 1400px) {
    .dashboard-grid.heatmap-row {
        grid-template-columns: 6fr 4fr;
        /* 더 좁은 화면에서 비율 정상화 */
    }
}

@media (max-width: 1200px) {

    .dashboard-grid,
    .dashboard-grid.heatmap-row {
        grid-template-columns: 1fr !important;
    }
}

.card {
    background: white;
    border-radius: 20px;
    padding: 28px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
}

.card-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-main);
}

.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    height: 180px;
}

.gauge-text {
    position: absolute;
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.gauge-value {
    font-size: 36px;
    font-weight: 900;
    color: var(--primary);
    letter-spacing: -1px;
}

.heatmap-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 12px;
    margin-top: 5px;
    width: 100%;
}

@media (max-width: 1550px) {
    .heatmap-grid {
        grid-template-columns: repeat(7, 1fr);
    }
}

@media (max-width: 1400px) {
    .heatmap-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 8px;
    }
}

@media (max-width: 1100px) {
    .heatmap-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1024px) {
    .heatmap-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 600px) {
    .heatmap-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.heatmap-cell {
    aspect-ratio: 1 / 1.25;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    cursor: help;
    border: 1px solid rgba(0, 0, 0, 0.05);
    background-color: #f1f5f9;
    padding: 10px 6px;
    min-width: 0;
    overflow: hidden;
}

.heatmap-cell:hover {
    transform: scale(1.05);
    z-index: 5;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.heatmap-cell .machine-num {
    font-size: 13px;
    font-weight: 850;
    line-height: 1;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding-bottom: 6px;
    margin-bottom: 4px;
    width: 90%;
    text-align: center;
    color: inherit;
}

.heatmap-cell .run-value {
    font-size: 22px;
    font-weight: 900;
    margin-bottom: 4px;
    line-height: 1;
    letter-spacing: -0.02em;
}

.heatmap-cell .info-row {
    font-size: 10px;
    font-weight: 700;
    line-height: 1.4;
    width: 100%;
    text-align: center;
    white-space: nowrap;
    margin-top: 2px;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
}

.legend-box {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 600px;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

th {
    background: #f8fafc;
    padding: 14px 20px;
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

td {
    padding: 14px 20px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.font-mono {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
    color: #475569;
}

.badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.badge-day {
    background: #fef3c7;
    color: #92400e;
}

.badge-night {
    background: #e0e7ff;
    color: #3730a3;
}

.issue-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    /* 모바일 너비 대응 */
    gap: 20px;
    margin-top: 10px;
}

.issue-block {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 150px;
    max-height: 450px;
    overflow-y: auto;
    position: relative;
}

.issue-block-title {
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 4px;
}

.issue-item {
    background: white;
    padding: 14px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.03);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    transition: transform 0.1s;
}

.issue-item:hover {
    border-color: #cbd5e1;
}

.issue-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.issue-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.issue-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.6;
    word-wrap: break-word;
}

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    z-index: 5000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    padding: 20px;
}

.modal-box {
    background: white;
    padding: 40px 60px 40px 40px;
    /* 우측 패딩을 더 넓게 설정(40->60) */
    border-radius: 24px;
    width: 90%;
    /* 모바일 대응을 위해 100% 대신 90% */
    max-width: 520px;
    /* 아주 소폭 늘려 여백 수용 */
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 90vh;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
    /* 패딩 포함 너비 계산 강제 */
}

@media (max-width: 480px) {
    .modal-box {
        padding: 30px 20px;
        /* 모바일에서도 적절한 여백 유지 */
    }
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}

.form-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-label {
    font-size: 12px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
}

.form-input,
.form-select {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    outline: none;
    background: #f8fafc;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary);
    background: white;
}

.form-textarea {
    width: 100%;
    height: 120px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.6;
    outline: none;
    resize: vertical;
    background: #f8fafc;
}

/* Rich Text Editor Styles */
.editor-toolbar {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    align-items: center;
}

.editor-toolbar button {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.editor-toolbar button:hover {
    background: #e2e8f0;
}

.editor-toolbar input[type="color"] {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0;
    width: 30px;
    height: 30px;
    cursor: pointer;
    background: white;
}

.editor-content {
    width: 100%;
    height: 140px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 0 0 12px 12px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.6;
    outline: none;
    overflow-y: auto;
    background: #ffffff;
    transition: border-color 0.2s;
}

.editor-content:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 28, 119, 0.1);
}

.editor-content:empty:before {
    content: attr(placeholder);
    color: #94a3b8;
    pointer-events: none;
    display: block;
}

.info-pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.info-pill {
    padding: 6px 12px;
    background: #f1f5f9;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    color: #475569;
}

.message-box {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: 12px;
    background: #1e293b;
    color: white;
    font-weight: 700;
    font-size: 14px;
    z-index: 9999;
    display: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

#confirmModal .modal-box {
    max-width: 400px;
    text-align: center;
}

#confirmModal h3 {
    margin-top: 0;
    color: var(--text-main);
    font-size: 18px;
}

#confirmModal p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}

#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    gap: 15px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.icon-btn {
    background: none;
    border: none;
    padding: 4px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateY(-1px);
}

/* Modern Minimal Business Tabs */
.top-tabs-wrapper {
    max-width: 1600px;
    /* .container와 동일하게 1600px */
    margin: 0 auto 16px auto;
    width: 95%;
    /* .container와 동일하게 95% */
    display: flex;
    padding: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.top-tabs-wrapper::-webkit-scrollbar {
    display: none;
}

.top-tabs {
    display: inline-flex;
    background: #f1f5f9;
    padding: 6px 8px;
    border-radius: 16px;
    border: 1px solid var(--border);
    position: relative;
    z-index: 20;
    gap: 4px;
}

.top-tab {
    position: relative;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    background: transparent;
    cursor: pointer;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 10;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
}

.top-tab svg {
    transition: transform 0.2s ease;
}

.top-tab:hover {
    color: var(--text-main);
    background: rgba(226, 232, 240, 0.6);
}

.top-tab:hover svg {
    transform: scale(1.1);
}

.top-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.main-view {
    display: none;
}

.main-view.active {
    display: flex;
}

/* Auth & Blur Styles */
body.unauthorized .main-view {
    filter: blur(10px);
    pointer-events: none;
    user-select: none;
    opacity: 0.8;
}

.auth-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.app-container {
    display: block;
    /* Original container based layout */
}

@media print {
    .controls-to-hide {
        display: none !important;
    }

    .btn-primary.btn-xs {
        display: none !important;
    }
}

/* Equipment Detail View & Chat UI */
.equip-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.equip-icon-box {
    width: 48px;
    height: 48px;
    background: #f1f5f9;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.equip-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.mini-kpi-card {
    background: #fff;
    border: 1px solid var(--border);
    padding: 12px 16px;
    border-radius: 16px;
}

.mini-kpi-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mini-kpi-value {
    font-size: 24px;
    font-weight: 900;
    color: var(--text-main);
}

.config-box {
    background: #f8fafc;
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 12px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.config-label {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
}

.config-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    border-radius: 20px;
    overflow: hidden;
    height: 620px;
    max-height: 620px;
    min-height: 0;
    border: 1px solid var(--border);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: block;
    background: #f1f5f9;
    /* 더 명확한 채팅창 배경색 */
}

.chat-date-divider {
    text-align: center;
    margin: 10px 0;
}

.chat-date-label {
    background: #e2e8f0;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
}

.chat-bubble-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 20px;
}

.chat-meta {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    margin-left: 4px;
}

.chat-bubble {
    background: #fff;
    padding: 16px 20px;
    border-radius: 12px 12px 12px 12px;
    /* 이미지처럼 둥근 사각형 형태 */
    font-size: 15px;
    font-weight: 500;
    color: var(--text-main);
    max-width: 95%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.02);
}

.chat-input-area {
    padding: 16px;
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input {
    flex: 1;
    border: none;
    background: #f1f5f9;
    padding: 12px 16px;
    border-radius: 24px;
    font-size: 13px;
    outline: none;
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.05);
}

.heatmap-cell {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    /* 상단 정렬로 통일 */
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.heatmap-cell:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 20px -8px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
}

.heatmap-icon-box {
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    color: #64748b;
    margin-bottom: 0;
}

.heatmap-cell.is-active .heatmap-icon-box {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #10B981;
    border: 2px solid #fff;
    border-radius: 50%;
    position: absolute;
    bottom: -2px;
    right: -2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.machine-id {
    font-size: 14px;
    font-weight: 850;
    color: inherit;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.machine-divider {
    width: 90%;
    height: 1.5px;
    background: rgba(0, 0, 0, 0.1);
    /* 회색 배경일 때 */
    margin: 2px 0;
}

.heatmap-cell.is-active .machine-id,
.heatmap-cell.is-active .machine-count-large {
    color: #000F43 !important;
    /* 더욱 깊은 남색 (최고 대비) */
    text-shadow: 0 0 4px rgba(255, 255, 255, 0.4);
    /* 미세한 광 효과로 가독성 보조 */
}

.heatmap-cell.is-active .machine-divider {
    background: rgba(0, 15, 67, 0.15);
}

.heatmap-cell.is-extreme-activity {
    box-shadow: 0 4px 12px rgba(0, 198, 193, 0.4);
    background: #00A6A1 !important;
    /* 더욱 진한 솔리드 컬러 */
    border: 2px solid rgba(0, 0, 0, 0.2) !important;
}

.heatmap-cell.is-extreme-activity .machine-id,
.heatmap-cell.is-extreme-activity .machine-count-large {
    color: #fff !important;
    /* 강도 최상이면 흰색 텍스트로 전환 (가독성 상향) */
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.heatmap-cell.is-high-activity {
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.1);
    /* 집중 가동 시 입체감 추가 */
}

.machine-count-large {
    font-size: 24px;
    /* 크기 축소 */
    font-weight: 950;
    line-height: 1;
    margin: 2px 0;
}

.wb-footer-badge {
    background: #BE1E3E;
    color: white;
    padding: 2px 6px;
    /* 패딩 대폭 축소 */
    border-radius: 8px;
    margin-top: auto;
    width: 95%;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
    /* 간격 축소 */
}

.wb-footer-label {
    font-size: 10px;
    font-weight: 950;
    display: block;
}

.wb-footer-percent {
    font-size: 9px;
    font-weight: 700;
}

.machine-recipe {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.wb-badge {
    background: #FF6767;
    color: white;
    font-size: 10px;
    font-weight: 900;
    padding: 3px 10px;
    border-radius: 12px;
    margin-bottom: 8px;
    text-transform: uppercase;
}

.heatmap-icon-box svg {
    width: 20px;
    height: 20px;
}

.heatmap-cell {
    padding: 12px 10px;
    gap: 4px;
    border: none;
    color: var(--text-muted);
    /* Fallback */
}

/* --- Responsive Refinements --- */
@media (max-width: 768px) {
    .control-bar {
        width: 100%;
        display: grid;
        /* 모바일에서 위젯을 정렬하기 위해 그리드 사용 */
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .control-bar>*,
    .control-bar .btn {
        width: 100%;
        justify-content: center;
    }

    .control-bar .search-input {
        width: 100% !important;
    }

    .kpi-value {
        font-size: 26px;
    }

    .card {
        padding: 16px;
    }

    .card-title {
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    .control-bar {
        grid-template-columns: 1fr;
    }

    .header-logo-group .logo-fallback {
        font-size: 20px;
    }

    .header-left h1 {
        font-size: 18px;
    }

    .kpi-value {
        font-size: 22px;
    }

    .kpi-card {
        padding: 16px;
    }

    .heatmap-cell {
        padding: 6px 4px;
    }

    .machine-id {
        font-size: 11px;
    }

    .machine-count-large {
        font-size: 18px;
    }

    .wb-footer-badge {
        padding: 2px 4px;
    }

    .wb-footer-label {
        font-size: 9px;
    }

    .modal-box {
        padding: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }
}

/* If active (has count), use dark text for better contrast on teal background */
.heatmap-cell.is-active {
    color: var(--primary);
    /* Deep Navy */
}

.heatmap-cell.is-active .machine-count-large {
    color: var(--primary);
}

.heatmap-cell.is-active .heatmap-icon-box {
    color: var(--primary);
    background: rgba(0, 0, 0, 0.05);
    /* Soften the icon box */
}

/* Selected state for multi-select (Interactive and Minimal green border) */
.heatmap-cell.is-selected {
    border: 2px solid #10B981 !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25) !important;
    transform: translateY(-2px);
}