:root {
    --primary: #2563EB;
    --primary-dark: #1D4FD7;
    --ink: #0F172A;
    --muted: #94A3B8;
    --muted2: #A6AEBC;
    --slate: #475569;
    --bg: #F4F6FA;
    --border: #EAEEF3;
    --border2: #D7DEE8;
    --success: #16A34A;
    --success-bg: #E7F6EC;
    --success-fg: #15803D;
    --danger: #DC2626;
    --danger-fg: #C53030;
    --danger-bg: #FDECEC;
    --warn-bg: #FEF3E2;
    --warn-fg: #B45309;
}

body {
    margin: 0;
    background: var(--bg);
    font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

.bc-appbar {
    height: 60px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.bc-brand { display: flex; align-items: center; gap: 10px; }
.bc-logo {
    width: 30px; height: 30px; border-radius: 9px; background: var(--primary);
    display: flex; align-items: center; justify-content: center;
}
.bc-brand-name { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }

.bc-appbar-right { display: flex; align-items: center; gap: 12px; }
.bc-avatar {
    width: 30px; height: 30px; border-radius: 50%; background: #DBEAFE;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 12px; color: var(--primary);
}
.bc-user { font-weight: 600; font-size: 14px; color: var(--slate); }

.bc-container { max-width: 1080px; margin: 0 auto; padding: 24px 20px 40px; }

.bc-page-title { font-weight: 800; font-size: 22px; letter-spacing: -0.02em; }
.bc-sub { color: var(--muted); font-size: 13px; }

.bc-card {
    background: #fff; border: 1px solid var(--border); border-radius: 14px;
    padding: 20px 22px; box-shadow: 0 1px 2px rgba(16,24,40,.04);
}

.bc-row { display: flex; gap: 18px; flex-wrap: wrap; }
.bc-row > * { flex: 1; min-width: 260px; }

.bc-badge {
    display: inline-flex; align-items: center; gap: 5px; height: 23px;
    padding: 0 9px; border-radius: 999px; font-weight: 600; font-size: 11.5px;
}
.bc-badge.online { background: var(--success-bg); color: var(--success-fg); }
.bc-badge.maintenance { background: var(--warn-bg); color: var(--warn-fg); }
.bc-badge.offline { background: #F1F5F9; color: #64748B; }
.bc-badge.danger { background: var(--danger-bg); color: var(--danger-fg); }
.bc-dot { width: 8px; height: 8px; border-radius: 50%; }
.bc-dot.online { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.14); }
.bc-dot.maintenance { background: #F59E0B; box-shadow: 0 0 0 3px rgba(245,158,11,.16); }
.bc-dot.offline { background: #CBD5E1; }

.bc-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 38px; padding: 0 16px; border-radius: 9px; font-weight: 600; font-size: 13.5px;
    cursor: pointer; border: 1px solid var(--border2); background: #fff; color: var(--slate);
    text-decoration: none; white-space: nowrap;
}
.bc-btn:hover { background: #F8FAFC; }
.bc-btn-primary { background: var(--primary); color: #fff; border: none; box-shadow: 0 6px 14px rgba(37,99,235,.22); }
.bc-btn-primary:hover { background: var(--primary-dark); }
.bc-btn-danger { border-color: #F1C7C7; color: #D33A3A; }
.bc-btn:disabled { opacity: .55; cursor: not-allowed; }

.bc-input {
    height: 42px; border: 1px solid var(--border2); border-radius: 10px; padding: 0 14px;
    font-size: 15px; color: var(--ink); background: #fff; outline: none;
    font-variant-numeric: tabular-nums;
}
.bc-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

.bc-money { font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.bc-table-wrap { border: 1px solid #EEF1F5; border-radius: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.bc-table { width: 100%; border-collapse: collapse; min-width: 460px; }
.bc-table th {
    padding: 12px 16px; text-align: left; font-weight: 600; font-size: 12.5px;
    color: #7A8699; border-bottom: 1px solid var(--border); background: #F8FAFC;
}
.bc-table td {
    padding: 12px 16px; font-size: 14px; border-bottom: 1px solid #F1F5F9; font-variant-numeric: tabular-nums;
}
.bc-empty { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; }

.bc-link-card { text-decoration: none; color: inherit; display: block; }
.bc-link-card:hover .bc-card { border-color: var(--primary); box-shadow: 0 8px 22px rgba(37,99,235,.12); }

.bc-divider { height: 1px; background: #F1F4F8; margin: 14px 0; }

.bc-pad-btn {
    height: 56px; border-radius: 12px; font-weight: 700; font-size: 15px; cursor: pointer;
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
.bc-pad-plus { border: 1px solid #D5E2FB; background: #EFF4FF; color: var(--primary); }
.bc-pad-minus { border: 1px solid #F4D2D2; background: #FDF1F1; color: var(--danger); }
.bc-pad-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }

.bc-total-box {
    margin-top: 16px; padding: 18px 20px; background: var(--ink); border-radius: 14px;
    display: flex; align-items: center; justify-content: space-between;
}
.bc-total-box .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.bc-total-box .value { color: #fff; font-weight: 800; font-size: 28px; font-variant-numeric: tabular-nums; }

/* 기기 목록 카드 (데스크톱: 가로, 모바일: 세로 스택) */
.bc-device-card { display: flex; align-items: center; gap: 24px; }
.bc-device-id { min-width: 230px; }
.bc-device-stat { flex: 1; min-width: 0; }
.bc-device-chevron { color: #C4CCD8; flex-shrink: 0; }

/* 시제 설정 행 */
.bc-float-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 0; border-bottom: 1px solid #F1F4F8; }
.bc-float-row .label { min-width: 110px; }
.bc-float-row .ctrl { display: flex; align-items: center; gap: 10px; }
.bc-float-row .ctrl .bc-input { width: 120px; text-align: right; }

@media (max-width: 640px) {
    .bc-user { display: none; }
    .bc-row > * { min-width: 100%; }
    .bc-container { padding: 16px 14px 32px; }

    .bc-device-card { flex-direction: column; align-items: stretch; gap: 12px; }
    .bc-device-id { min-width: 0; }
    .bc-device-chevron { display: none; }

    .bc-pad-grid { gap: 8px; }
    .bc-pad-btn { height: 50px; font-size: 13px; }

    .bc-float-row .label { min-width: 0; }
    .bc-float-row .ctrl { gap: 8px; }
    .bc-float-row .ctrl .bc-input { width: 88px; }

    .bc-table th, .bc-table td { padding: 10px 12px; }
}

/* ── 관리자 레이아웃 (사이드바 + 콘텐츠) ───────────────────────── */
.bc-admin-shell { display: flex; min-height: 100vh; }

.bc-admin-sidebar {
    width: 240px; flex-shrink: 0; box-sizing: border-box;
    background: #fff; border-right: 1px solid var(--border);
    padding: 16px 14px; position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 16px;
}
.bc-admin-brand { display: flex; align-items: center; gap: 8px; padding: 6px 8px; text-decoration: none; color: inherit; }
.bc-admin-brand-mobile { display: none; align-items: center; gap: 8px; text-decoration: none; color: inherit; }
.bc-admin-tag { font-size: 11px; font-weight: 700; color: var(--primary); background: #EFF4FF; padding: 2px 7px; border-radius: 999px; }

.bc-admin-nav { display: flex; flex-direction: column; gap: 4px; }
.bc-admin-nav-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
    text-decoration: none; color: var(--slate); font-weight: 600; font-size: 14px; white-space: nowrap;
}
.bc-admin-nav-item:hover { background: #F8FAFC; }
.bc-admin-nav-item.active { background: #EFF4FF; color: var(--primary); }

.bc-admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bc-admin-topbar {
    height: 60px; background: #fff; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: flex-end; padding: 0 24px;
    position: sticky; top: 0; z-index: 10;
}
.bc-admin-content { width: 100%; max-width: 1180px; box-sizing: border-box; margin: 0 auto; padding: 24px 24px 40px; }

@media (max-width: 640px) {
    .bc-admin-shell { flex-direction: column; }
    .bc-admin-sidebar {
        width: auto; height: auto; position: static; flex-direction: row; align-items: center;
        gap: 8px; padding: 10px 12px; overflow-x: auto; border-right: none; border-bottom: 1px solid var(--border);
    }
    .bc-admin-brand { display: none; }
    .bc-admin-brand-mobile { display: flex; margin-right: auto; }
    .bc-admin-nav { flex-direction: row; gap: 6px; }
    .bc-admin-content { padding: 16px 14px 32px; }
}

/* ── 대시보드 지표 카드 ───────────────────────────────────── */
.bc-metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.bc-metric-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.bc-metric-value { font-weight: 800; font-size: 26px; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.bc-metric-sub { color: var(--slate); font-size: 12.5px; margin-top: 6px; }
.bc-statusbar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; margin-top: 12px; background: #EEF2F7; }
.bc-statusbar > span { display: block; height: 100%; }
.bc-statusbar .on { background: var(--success); }
.bc-statusbar .mt { background: #F59E0B; }
.bc-statusbar .off { background: #CBD5E1; }
.bc-legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; color: var(--slate); }
.bc-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* ── 툴바 / 검색 / 필터 칩 ────────────────────────────────── */
.bc-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.bc-toolbar .grow { flex: 1; min-width: 160px; }
.bc-chip {
    height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border2);
    background: #fff; color: var(--slate); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.bc-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── 행 액션 / 메뉴 ──────────────────────────────────────── */
.bc-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.bc-btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.bc-row-blocked { opacity: .55; }

/* ── 모달 ────────────────────────────────────────────────── */
.bc-modal-backdrop {
    position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 50;
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.bc-modal {
    background: #fff; border-radius: 16px; width: 100%; max-width: 460px; padding: 24px;
    box-shadow: 0 20px 50px rgba(16,24,40,.25);
}
.bc-modal-title { font-weight: 800; font-size: 18px; }
.bc-modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; }
.bc-modal textarea.bc-input { height: auto; min-height: 96px; padding: 10px 12px; width: 100%; box-sizing: border-box; resize: vertical; font-family: inherit; }

/* ── 토글 스위치 ─────────────────────────────────────────── */
.bc-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.bc-switch .track { width: 38px; height: 22px; border-radius: 999px; background: #CBD5E1; position: relative; transition: background .15s; }
.bc-switch .track .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.bc-switch.on .track { background: var(--primary); }
.bc-switch.on .track .knob { left: 18px; }

/* ── 페이저 ──────────────────────────────────────────────── */
.bc-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.bc-pager .info { color: var(--muted); font-size: 13px; }
.bc-pager .nav { display: flex; gap: 8px; }

@media (max-width: 900px) { .bc-metric-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .bc-metric-grid { grid-template-columns: 1fr; } }
