/* ══════════════════════════════════════════════════════════════
   TabSpace 표준 디자인 시스템 (custom.css)
   ────────────────────────────────────────────────────────────
   - 폰트     : 에이투지체(ATOZ) 300~700 + Pretendard fallback
   - 브랜드   : Indigo #4F46E5 (--primary-600). 프로젝트별 --primary-* 오버라이드 가능
   - 기본크기 : 17px (모바일 16px)
   - 레이아웃 : 좌측 고정 사이드바(256/72px) + 상단 고정 탑바(56px)
   - 전환     : 공유 레이아웃 + View Transitions 무깜빡임 보강
   - 다크모드 : html.dark 클래스 + CSS 변수
   사용처: Tailwind CDN 과 함께 사용. 자세한 규칙은 GUIDELINE.md 참고.
   ══════════════════════════════════════════════════════════════ */

/* ── 폰트 (에이투지체 / ATOZ) ── */
@font-face { font-family:'ATOZ'; src:url('../fonts/ATOZ-3Light.woff2')    format('woff2'); font-weight:300; font-style:normal; font-display:swap; }
@font-face { font-family:'ATOZ'; src:url('../fonts/ATOZ-4Regular.woff2')  format('woff2'); font-weight:400; font-style:normal; font-display:swap; }
@font-face { font-family:'ATOZ'; src:url('../fonts/ATOZ-5Medium.woff2')   format('woff2'); font-weight:500; font-style:normal; font-display:swap; }
@font-face { font-family:'ATOZ'; src:url('../fonts/ATOZ-6SemiBold.woff2') format('woff2'); font-weight:600; font-style:normal; font-display:swap; }
@font-face { font-family:'ATOZ'; src:url('../fonts/ATOZ-7Bold.woff2')     format('woff2'); font-weight:700; font-style:normal; font-display:swap; }

/* ── 디자인 토큰 (Light) ──
   브랜드 색을 바꾸려면 --primary-50 ~ --primary-900 만 재정의하면 전체 테마가 따라옵니다.
   ────────────────────────────────────────────── */
:root {
    /* 브랜드 (Indigo) — 기본값 */
    --primary-900: #312e81;
    --primary-800: #3730a3;
    --primary-700: #4338ca;
    --primary-600: #4f46e5;   /* ★ TabSpace 대표색 */
    --primary-500: #6366f1;
    --primary-400: #818cf8;
    --primary-300: #a5b4fc;
    --primary-200: #c7d2fe;
    --primary-100: #e0e7ff;
    --primary-50:  #eef2ff;

    /* 상태색 */
    --success-700: #047857;
    --success-600: #059669;
    --success-100: #d1fae5;
    --success-50:  #ecfdf5;

    --error-700: #b91c1c;
    --error-600: #dc2626;
    --error-100: #fee2e2;
    --error-50:  #fef2f2;

    --warning-700: #b45309;
    --warning-600: #d97706;
    --warning-100: #fef3c7;
    --warning-50:  #fffbeb;

    --info-600: #0284c7;
    --info-100: #e0f2fe;

    --offline-600: #6b7280;
    --offline-100: #f3f4f6;
    --offline-50:  #f9fafb;

    /* 레이아웃 치수 */
    --sidebar-w: 256px;
    --sidebar-collapsed: 72px;
    --topbar-h: 56px;

    /* 표면/경계/배경 */
    --page-bg: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --bg-secondary: #f8fafc;

    /* 타이포 */
    --font-body: 'ATOZ', 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', sans-serif;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;

    /* 반경 */
    --radius-sm: 0.5rem;     /* 버튼 8px */
    --radius-md: 0.625rem;   /* 입력 10px */
    --radius-lg: 0.75rem;    /* 카드 12px */
    --radius-xl: 1.125rem;   /* 모달 18px */
}

/* ── 디자인 토큰 (Dark) ── */
html.dark {
    --page-bg: #0f172a;
    --card-bg: #1e293b;
    --border-color: #334155;
    --border-light: #1e293b;
    --bg-secondary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    /* 다크에서 hover/active 배경으로 쓰는 옅은 색만 어둡게 재정의 */
    --primary-50:  #1e1b4b;
    --primary-100: #312e81;
    --success-50:  #064e3b;
    --success-100: #065f46;
    --error-50:    #450a0a;
    --error-100:   #7f1d1d;
    --warning-50:  #451a03;
    --warning-100: #78350f;
    --offline-50:  #1e293b;
    --offline-100: #334155;
}

/* ── 리셋 & 기본 타이포 ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 17px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body {
    font-family: var(--font-body);
    background: var(--page-bg);
    color: var(--text-primary);
    min-height: 100vh;
    font-weight: 300;
    line-height: 1.6;
    font-size: 1rem;
}
h1, h2, h3, h4, h5, h6 { color: var(--text-primary); font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.75rem; }    /* ≈ 29.75px */
h2 { font-size: 1.375rem; }   /* ≈ 23.4px  */
h3 { font-size: 1.125rem; }   /* ≈ 19.1px  */
h4 { font-size: 1rem; }       /* = 17px    */
a { color: inherit; text-decoration: none; }
img, svg { display: block; max-width: 100%; }

/* ── 무깜빡임 페이지 전환 (Cross-document View Transitions) ──
   공유 base 레이아웃 + 아래 opt-in 으로 전환 시 깜빡임을 제거합니다.
   사이드바/탑바는 고유 이름을 부여해 전환 중 '고정'되어 보입니다.
   미지원 브라우저는 자동으로 일반 전환으로 폴백합니다. */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: app-sidebar; }
.topbar  { view-transition-name: app-topbar; }
/* 모션 최소화 선호 시: 전환 애니메이션 비활성 (표준 권장 방식) */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) { animation: none !important; }
}

/* ══════════════════════════════════════════════════════════════
   레이아웃
   ══════════════════════════════════════════════════════════════ */
.layout { display: flex; min-height: 100vh; }

/* ── 사이드바 (좌측 고정) ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--card-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 40;
    display: flex;
    flex-direction: column;
    transition: width 0.25s cubic-bezier(.4,0,.2,1), transform 0.25s cubic-bezier(.4,0,.2,1);
    overflow-x: hidden;
}
.sidebar-logo-wrap {
    display: flex; align-items: center;
    height: var(--topbar-h);
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0; position: relative;
}
.sidebar-logo { display: flex; align-items: center; gap: 12px; flex: 1; }
.sidebar-logo .logo-box {
    width: 36px; height: 36px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff; font-weight: 800; font-size: 1rem;
}
.sidebar-logo .logo-text h1 { font-size: 0.9375rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.sidebar-logo .logo-sub { font-size: 0.6875rem; color: var(--text-muted); line-height: 1.2; }

/* 네비게이션 */
.sidebar-nav { flex: 1; overflow-y: auto; padding: 0.75rem 0; }
.nav-section {
    padding: 1rem 1.25rem 0.4rem;
    font-size: 10px; font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}
.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px;
    font-size: 0.9375rem; font-weight: 300;
    color: var(--text-secondary);
    border-right: 3px solid transparent;
    transition: all 0.18s cubic-bezier(.4,0,.2,1);
    position: relative;
    white-space: nowrap;
}
.nav-link:hover { background: var(--primary-50); color: var(--primary-700); }
.nav-link.active {
    background: var(--primary-50);
    color: var(--primary-700);
    border-right-color: var(--primary-500);
    font-weight: 500;
}
.nav-link.active::before {
    content: '';
    position: absolute; left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    background: var(--primary-500);
    border-radius: 0 3px 3px 0;
}
.nav-link svg, .nav-link .nav-icon {
    width: 22px; height: 22px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.15s;
}
.nav-link:hover svg, .nav-link:hover .nav-icon { transform: scale(1.08); }

/* 사이드바 푸터 */
.sidebar-footer {
    min-height: var(--topbar-h);
    padding: 0.5rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}
.sidebar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
    background: linear-gradient(135deg, var(--primary-100), var(--primary-200));
    color: var(--primary-700);
    flex-shrink: 0;
}
.sidebar-user { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.8125rem; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-role { font-size: 0.6875rem; color: var(--text-muted); }
/* 로그아웃 버튼 — 항상 보이는 전용 아이콘 버튼 */
.sidebar-logout {
    flex-shrink: 0;
    width: 34px; height: 34px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
}
.sidebar-logout:hover { background: var(--error-50); color: var(--error-600); border-color: var(--error-100); }

/* ── 탑바 (상단 고정) ── */
.topbar {
    height: var(--topbar-h);
    background: rgba(255,255,255,0.92);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem;
    position: fixed; top: 0; left: var(--sidebar-w); right: 0;
    z-index: 30;
    transition: left 0.25s cubic-bezier(.4,0,.2,1);
}
html.dark .topbar { background: rgba(30,41,59,0.92); }
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
#live-clock { font-size: 0.75rem; font-weight: 600; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* 햄버거 / 모바일 로고 (기본 숨김, 모바일에서 노출) */
.nav-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px;
    border: none; background: none; cursor: pointer;
    border-radius: 8px; color: var(--text-secondary);
}
.nav-toggle:hover { background: var(--primary-50); color: var(--primary-700); }
.mobile-logo { display: none; }
.sidebar-close-btn { display: none; }

/* 티커 (선택) — 상단 공지/인사이트 흐름 */
.ticker-wrap {
    flex: 1; margin: 0 1rem; overflow: hidden; height: 20px; line-height: 20px;
    -webkit-mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent);
    mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent);
}
.ticker-track { display: inline-block; white-space: nowrap; font-size: 0.8125rem; color: var(--text-secondary); }
.ticker-track.scrolling { animation: tickerScroll var(--ticker-duration, 40s) linear infinite; }
.ticker-track:hover { animation-play-state: paused; }
@keyframes tickerScroll { 0% { transform: translateX(0); } 100% { transform: translateX(-50%); } }

/* ── 메인 콘텐츠 ── */
.main { flex: 1; margin-left: var(--sidebar-w); transition: margin-left 0.25s cubic-bezier(.4,0,.2,1); min-width: 0; overflow-x: hidden; }
.content { padding: 1.5rem; padding-top: calc(var(--topbar-h) + 1.5rem); max-width: 100%; }
.page-fade { animation: fadeIn 0.3s ease; }

/* 사이드바 오버레이 (모바일 오프캔버스 배경) — app.js가 body에 생성/제거.
   전역 정의: opacity:0+pointer-events:none 라 평소 비가시. .open 시에만 노출. */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 35; opacity: 0; pointer-events: none; transition: opacity 0.25s; }
.sidebar-overlay.open { opacity: 1; pointer-events: auto; }

/* ── 데스크톱 사이드바 접힘 (아이콘 레일) ──
   body.nav-collapsed 토글. 데스크톱(≥1024px)에서만 적용. */
@media (min-width: 1024px) {
    body.nav-collapsed .sidebar { width: var(--sidebar-collapsed); }
    body.nav-collapsed .main    { margin-left: var(--sidebar-collapsed); }
    body.nav-collapsed .topbar  { left: var(--sidebar-collapsed); }
    body.nav-collapsed .nav-label,
    body.nav-collapsed .nav-section,
    body.nav-collapsed .logo-text,
    body.nav-collapsed .sidebar-user,
    body.nav-collapsed .sidebar-logout { display: none; }
    body.nav-collapsed .nav-link { justify-content: center; padding: 10px 0; }
    body.nav-collapsed .sidebar-logo { justify-content: center; }
    body.nav-collapsed .sidebar-footer { justify-content: center; }
}

/* ══════════════════════════════════════════════════════════════
   컴포넌트
   ══════════════════════════════════════════════════════════════ */

/* ── 카드 ── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.02);
    transition: box-shadow 0.2s cubic-bezier(.4,0,.2,1), transform 0.2s;
    overflow: hidden;
}
.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.03); }
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600; font-size: 0.95rem;
    display: flex; align-items: center; justify-content: space-between;
    color: var(--text-primary);
}
.card-body { padding: 1.25rem; }

/* ── KPI 카드 ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1.5rem; }
.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary-500);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: transform 0.2s cubic-bezier(.4,0,.2,1), box-shadow 0.2s;
    position: relative; overflow: hidden;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: 0 8px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04); }
.kpi-card.success { border-left-color: var(--success-600); }
.kpi-card.error   { border-left-color: var(--error-600); }
.kpi-card.warning { border-left-color: var(--warning-600); }
.kpi-card.info    { border-left-color: var(--info-600); }
.kpi-card.offline { border-left-color: var(--offline-600); }
.kpi-label { font-size: 0.8125rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.25rem; }
.kpi-value { font-size: 2rem; font-weight: 700; line-height: 1.2; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.kpi-sub   { font-size: 0.6875rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── 버튼 ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.5rem 1.125rem;
    font-size: 0.875rem; font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.15s; cursor: pointer; border: none;
    font-family: inherit; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none !important; }
.btn-primary {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-600));
    color: #fff; box-shadow: 0 1px 3px rgba(79,70,229,0.2);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    box-shadow: 0 3px 10px rgba(79,70,229,0.3); transform: translateY(-1px);
}
.btn-secondary { background: var(--card-bg); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--bg-secondary); }
.btn-danger  { background: var(--error-600); color: #fff; }
.btn-danger:hover { background: var(--error-700); }
.btn-success { background: var(--success-600); color: #fff; }
.btn-success:hover { background: var(--success-700); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-ghost:hover { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-300); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* ── 배지 ── */
.badge {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.1875rem 0.75rem;
    font-size: 0.8125rem; font-weight: 500;
    border-radius: 9999px; border: 1px solid transparent;
}
.badge-online, .badge-green  { background: var(--success-50); color: var(--success-700); border-color: #bbf7d0; }
.badge-offline               { background: var(--offline-100); color: var(--offline-600); border-color: #d1d5db; }
.badge-alarm, .badge-red     { background: var(--error-50);  color: var(--error-700);  border-color: #fecaca; }
.badge-warning, .badge-amber { background: var(--warning-50); color: var(--warning-700); border-color: #fde68a; }
.badge-blue                  { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
html.dark .badge-online, html.dark .badge-green  { background: #064e3b; color: #6ee7b7; border-color: #065f46; }
html.dark .badge-alarm,  html.dark .badge-red    { background: #7f1d1d; color: #fca5a5; border-color: #991b1b; }
html.dark .badge-warning,html.dark .badge-amber  { background: #78350f; color: #fcd34d; border-color: #92400e; }
html.dark .badge-blue                            { background: #1e3a5f; color: #93c5fd; border-color: #1e40af; }

/* ── 상태 점 ── */
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online  { background: var(--success-600); box-shadow: 0 0 0 3px var(--success-100); }
.status-dot.offline { background: var(--offline-600); box-shadow: 0 0 0 3px var(--offline-100); }
.status-dot.alarm   { background: var(--error-600); box-shadow: 0 0 0 3px var(--error-100); animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 3px var(--error-100); } 50% { box-shadow: 0 0 0 6px rgba(220,38,38,0.1); } }

/* ── 테이블 (.pro-table) — 모바일에서 카드로 변환 ── */
.pro-table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.pro-table thead { background: var(--bg-secondary); }
.pro-table th {
    text-align: left; padding: 0.75rem 1rem;
    font-size: 0.75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-secondary); border-bottom: 1px solid var(--border-color);
}
.pro-table td { padding: 0.875rem 1rem; border-bottom: 1px solid var(--border-light); color: var(--text-primary); }
.pro-table tbody tr { transition: background 0.1s; }
.pro-table tbody tr:hover { background: rgba(0,0,0,0.02); }
html.dark .pro-table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ── 폼 입력 ── */
.form-input {
    width: 100%; padding: 0.6875rem 0.875rem;
    background: var(--card-bg); border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.875rem; font-family: inherit; color: var(--text-primary);
    outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.form-input:focus { border-color: var(--primary-500); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.form-input::placeholder { color: var(--text-muted); }
.form-label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.375rem; }

/* ── 토글 스위치 ── */
.toggle-switch { position: relative; display: inline-block; width: 48px; height: 26px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 13px; cursor: pointer; transition: 0.25s; }
.toggle-slider::before { content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: 0.25s; }
.toggle-switch input:checked + .toggle-slider { background: var(--primary-500); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

/* ── 다크모드 토글 버튼 ── */
.theme-toggle {
    width: 34px; height: 34px; border-radius: 8px;
    border: 1px solid var(--border-color); background: var(--card-bg);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: var(--text-secondary); transition: all 0.15s;
}
.theme-toggle:hover { background: var(--primary-50); border-color: var(--primary-300); color: var(--primary-700); }

/* ── 모달 ── */
.modal-backdrop {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(17,24,39,0.5); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
    animation: modalBgIn 0.2s ease;
}
.modal-card {
    background: var(--card-bg); border-radius: var(--radius-xl);
    box-shadow: 0 25px 60px rgba(0,0,0,0.18);
    width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
    animation: modalCardIn 0.25s cubic-bezier(.21,1.02,.73,1);
}
@keyframes modalBgIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalCardIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ── 토스트 ── */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
    padding: 12px 20px; border-radius: var(--radius-md); color: #fff;
    font-size: 0.85rem; font-weight: 500; box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    animation: toastSlideIn 0.3s ease; position: relative; overflow: hidden;
    display: flex; align-items: center; gap: 12px;
}
.toast::after { content: ''; position: absolute; bottom: 0; left: 0; height: 3px; width: 100%; background: rgba(255,255,255,0.4); animation: toastProgress 3s linear forwards; }
.toast.success { background: var(--success-600); }
.toast.error   { background: var(--error-600); }
.toast.warning { background: var(--warning-600); }
.toast.info    { background: var(--primary-600); }
@keyframes toastSlideIn { from { opacity: 0; transform: translateX(30px) scale(0.95); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toastProgress { from { width: 100%; } to { width: 0%; } }

/* ── 스켈레톤 (로딩) ── */
.skeleton {
    background: linear-gradient(90deg, var(--border-color) 25%, var(--border-light) 50%, var(--border-color) 75%);
    background-size: 200% 100%; animation: shimmer 1.5s infinite;
    border-radius: 8px; display: inline-block; min-width: 40px; min-height: 1em;
}
@keyframes shimmer { 0% { background-position: -200px 0; } 100% { background-position: calc(200px + 100%) 0; } }

/* ── 그리드 유틸 ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }

/* ── 기타 유틸 ── */
.hidden { display: none !important; }

/* ── 공용 애니메이션 ── */
@keyframes fadeIn  { from { opacity: 0; transform: translateY(8px); }  to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin    { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════
   반응형 — 데스크톱 우선, 1024px / 640px 분기
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 1200px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }

@media (max-width: 1023px) {
    /* 사이드바: 오프캔버스(좌측 슬라이드인) */
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.2); }
    .main { margin-left: 0; }
    .topbar { left: 0; padding: 0 1rem; }
    .mobile-logo { display: flex; align-items: center; justify-content: center; }
    .sidebar-close-btn { display: block; }
    .ticker-wrap { display: none; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    html { font-size: 16px; }                 /* 모바일 본문 16px */
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .kpi-value { font-size: 1.5rem; }
    .content { padding: 0.875rem; padding-top: calc(var(--topbar-h) + 0.875rem); }
    .topbar-title { font-size: 0.875rem; }
    .topbar-right { gap: 0.5rem; }
    .card-body { padding: 1rem; }

    /* 테이블 → 카드 변환: <td data-label="컬럼명"> 필요 */
    .pro-table thead { display: none; }
    .pro-table tr { display: block; border-bottom: 1px solid var(--border-color); padding: 0.5rem 0; }
    .pro-table td { display: flex; justify-content: space-between; align-items: center; border: none; padding: 0.3rem 1rem; }
    .pro-table td::before {
        content: attr(data-label);
        font-weight: 600; font-size: 0.75rem;
        text-transform: uppercase; letter-spacing: 0.04em;
        color: var(--text-secondary); margin-right: 1rem;
    }
}

/* ══ 바로닷 프로젝트 확장 — 표준 외 최소 추가, 토큰만 사용 (components.md 작성 규칙 준수) ══ */
.card-header h2 { font-size: 0.95rem; font-weight: 600; }
.alert-warning {
  font-size: 0.875rem; color: var(--warning-700); background: var(--warning-50);
  border-radius: var(--radius-sm); padding: 0.75rem 1rem; margin-bottom: 1rem;
}
html.dark .alert-warning { color: #fcd34d; background: var(--warning-100); } /* 다크 warning-100=#78350f */
.form-error { display: none; color: var(--error-600); font-size: 0.8125rem; margin-bottom: 0.875rem; }
html.dark .form-error { color: #fca5a5; }
.legend-swatch { width: 0.875em; height: 0.1875em; display: inline-block; border-radius: 1px; }
/* 매핑 UI 신규 컴포넌트 (DESIGN §8 — 토큰만 사용) */
.candidate-option {
  display: flex; align-items: center; gap: 0.75rem; width: 100%; text-align: left;
  padding: 0.625rem 0.875rem; border: 2px solid var(--border-color); border-radius: var(--radius-md);
  background: var(--card-bg); cursor: pointer; transition: border-color 0.12s, background 0.12s;
}
.candidate-option:hover { border-color: var(--primary-300); }
.candidate-option.selected { border-color: var(--primary-500); background: var(--primary-50); }
.candidate-option .cand-key {
  width: 1.5rem; height: 1.5rem; border-radius: 6px; background: var(--bg-secondary);
  color: var(--text-secondary); font-size: 0.75rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.candidate-option.selected .cand-key { background: var(--primary-500); color: #fff; }
.cand-main { flex: 1; min-width: 0; }
.cand-name { font-weight: 600; color: var(--text-primary); font-size: 0.9375rem; }
.cand-desc { font-size: 0.75rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-bar { width: 4.5rem; height: 0.375rem; border-radius: 999px; background: var(--bg-secondary); overflow: hidden; flex-shrink: 0; }
.score-bar > span { display: block; height: 100%; background: var(--primary-500); }
.queue-row { cursor: pointer; }
.queue-row.active td { background: var(--primary-50); }
html.dark .queue-row.active td { background: var(--primary-900); }
.cand-score { font-size: 0.75rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.cand-unit { color: var(--text-muted); font-weight: 400; }
.cell-empty { color: var(--text-muted); }
