:root {
    --bg-main: #0b0e14;
    --bg-card: rgba(23, 28, 41, 0.85);
    --bg-accent: rgba(30, 41, 59, 0.4);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --primary: #8b5cf6;
    --cyan: #06b6d4;
    --magenta: #d946ef;
    --yellow: #eab308;
    --black: #334155;
    --success: #10b981;
    --error: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Noto Sans KR', sans-serif;
}

body {
    background: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    padding: 0 15px;
    background-image: radial-gradient(circle at 50% 50%, #1e293b 0%, #0b0e14 100%);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-header {
    height: 60px;
    /* 고정 높이 최적화 */
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logo-text {
    font-size: 1.8rem;
    font-weight: 900;
    letter-spacing: 2px;
    background: linear-gradient(135deg, #fff 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-sub {
    margin-left: 15px;
    font-size: 1.8rem;
    /* 로고와 크기 맞춤 */
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 10px rgba(139, 92, 246, 0.3);
}

/* New Master Layout: Main(Split-V) + Sidebar(H) */
.master-layout {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    /* 스테이션 영역 비율을 더 축소하여 균형 확보 */
    gap: 15px;
    height: calc(100vh - 110px);
    margin-top: 10px;
}

/* Main Content Area (Horizontal Split) */
.station-area {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 5px;
    align-items: stretch;
}

.station-area::-webkit-scrollbar {
    height: 6px;
}

.station-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.station-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 250px;
    /* 폭 축소 */
    max-width: 320px;
    /* 고정폭 느낌 강화 */
}

.section-title {
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

/* Status Unit Design */
.status-unit {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-right: 0;
    padding-bottom: 12px;
    flex-shrink: 0;
}

.unit-id {
    font-weight: 900;
    font-size: 1.15rem;
    /* 글자 크기 미세 조정 */
    color: var(--cyan);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
}

.unit-2 .unit-id {
    color: var(--magenta);
}

.unit-3 .unit-id {
    color: var(--yellow);
}

.toner-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}

.toner-gauge {
    height: 60px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.toner-fill {
    position: absolute;
    bottom: 0;
    width: 100%;
    transition: height 1s;
}

.toner-val {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.6rem;
    font-weight: 900;
    text-shadow: 0 0 3px #000;
    z-index: 2;
}

/* Queue List inside rows - One Line Style */
.queue-panel {
    background: var(--bg-accent);
    border-radius: 10px;
    padding: 10px;
    overflow-y: auto;
    height: 100%;
}

.job-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.95rem;
}

.job-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

.job-meta {
    color: var(--text-secondary);
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Paper Tray - One Line Style (3-Step Blocks) */
.paper-tray {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 38px;
}

.tray-blocks {
    display: flex;
    gap: 3px;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tray-block {
    width: 16px;
    height: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    transition: background 0.3s;
}

.tray-block.filled {
    background: #4ade80;
    /* Good level green */
    box-shadow: 0 0 5px rgba(74, 222, 128, 0.3);
}

.tray-block.low {
    background: #fbbf24;
    /* Low level orange */
    box-shadow: 0 0 5px rgba(251, 191, 36, 0.3);
}

.level-text {
    font-size: 0.8rem;
    font-weight: 800;
    margin-left: 5px;
}

.level-text.empty {
    color: #f87171;
}

.level-text.low {
    color: #fbbf24;
}

.level-text.good {
    color: #4ade80;
}

.tray-label {
    font-weight: 800;
    color: var(--text-secondary);
    min-width: 25px;
    opacity: 0.6;
}

/* Sidebar Control Center */
.control-sidebar {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* 내부 요소가 넘치지 않도록 강제 */
    max-height: 100%;
}

.upload-zone {
    border: 1.5px dashed var(--primary);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    background: rgba(139, 92, 246, 0.05);
    margin-bottom: 12px;
}

.upload-zone p {
    font-size: 0.8rem;
    font-weight: 700;
    margin-top: 5px;
}

.analysis-report {
    flex: 1;
    height: 100%;
    /* 부모 높이 전체 사용 */
    min-height: 0;
    /* flex 아이템의 최소 높이 제한 해제 */
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 12px;
    overflow-y: auto;
    font-size: 0.95rem;
    margin-bottom: 0;
    /* 하단 마진 제거하여 높이 계산 오류 방지 */
}

/* 스크롤바 디자인 커스텀 (가독성 향상) */
.analysis-report::-webkit-scrollbar {
    width: 6px;
    display: block;
    /* 스크롤바 표시 */
}

.analysis-report::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.3);
    border-radius: 10px;
}

.map-row {
    display: grid;
    grid-template-columns: 120px 80px 1fr;
    /* 폭 최적화 */
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tag-color,
.tag-bw {
    padding: 3px 6px;
    /* 패딩 축소 */
    border-radius: 4px;
    font-size: 0.8rem;
    /* 약간 축소 */
    font-weight: 800;
    text-align: center;
    min-width: 60px;
}

.tag-color {
    background: rgba(217, 70, 239, 0.2);
    color: var(--magenta);
    border: 1px solid var(--magenta);
}

.tag-bw {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-secondary);
    border: 1px solid var(--text-secondary);
}

/* Info Rows (Counters, IPs) */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.9rem;
    padding: 4px 0;
}

.info-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.info-value {
    color: var(--text-primary);
    font-weight: 900;
    font-size: 1.1rem;
}

.text-magenta {
    color: var(--magenta) !important;
}

.text-accent {
    color: var(--cyan) !important;
}

.text-yellow {
    color: #fbbf24 !important;
}

/* Badges */
.badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid currentColor;
    transition: all 0.2s;
}

.badge:hover {
    background: currentColor;
    color: var(--bg-main) !important;
}

.badge.online {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.badge.warning {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
    animation: pulse-warning 2s infinite;
}

.badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    animation: pulse-error 1s infinite;
}

.badge.offline {
    background: rgba(100, 116, 139, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(100, 116, 139, 0.3);
}

@keyframes pulse-warning {
    0% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
    }
}

@keyframes pulse-error {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
        transform: scale(1);
    }

    50% {
        box-shadow: 0 0 0 15px rgba(239, 68, 68, 0);
        transform: scale(1.05);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
        transform: scale(1);
    }
}

/* Control Buttons */
.btn-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.main-btn {
    height: 44px;
    /* 높이 약간 감소 */
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    /* 버튼 글자 크기 소폭 하향 */
    font-weight: 800;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: 0.2s;
}

.btn-color {
    background: linear-gradient(135deg, #06b6d4, #d946ef);
}

.btn-bw {
    background: #334155;
}

.btn-opt {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    grid-column: span 2;
    height: 48px;
    font-size: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.app-footer {
    text-align: center;
    height: 30px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Badges */
.badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid currentColor;
    transition: all 0.2s;
}

.badge:hover {
    background: currentColor;
    color: var(--bg-main) !important;
}

.online {
    color: var(--success);
}

.offline {
    color: var(--error);
}