: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-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-btn:disabled { opacity: .35; cursor: not-allowed; }
.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-ex-sum {
    display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
    padding: 11px 14px; margin-top: 8px; border-radius: 10px; background: #F8FAFC;
}
.bc-ex-sum .label { font-weight: 700; font-size: 13.5px; color: var(--slate); }
.bc-ex-sum .value {
    font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em;
}
.bc-ex-sum.in .value { color: var(--primary); }
.bc-ex-sum.out .value { color: var(--ink); }

/* 미배출금 — 0원이 아닐 때만 눈에 띄게. 나가지 못한 돈이 쌓였다는 신호다 */
.bc-ex-sum.undispensed { background: var(--warn-bg); }
.bc-ex-sum.undispensed .label, .bc-ex-sum.undispensed .value { color: var(--warn-fg); }

/* 목록 합과 총합이 어긋날 때만 나오는 경고 — 장치 전송 이상 신호 */
.bc-ex-mismatch {
    margin-top: 8px; padding: 9px 12px; border-radius: 8px;
    background: var(--warn-bg); color: var(--warn-fg);
    font-size: 12.5px; line-height: 1.5; font-weight: 600;
}

/* 기기 목록 카드 (데스크톱: 가로, 모바일: 세로 스택) */
.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-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-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; } }

/* ── 회원 기기 화면 ─────────────────────
   일반 회원은 주로 휴대폰으로 보므로, 주요 기능이 한 화면에 들어오도록 여백과 세로 길이를 줄인다. */
.bc-compact .bc-card { padding: 18px; }
.bc-compact .bc-row { gap: 14px; }

.bc-dev-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.bc-dev-head-top { display: flex; align-items: center; gap: 10px; }
.bc-dev-head-title { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.bc-dev-head-title.danger { color: #D33A3A; }
.bc-dev-head-actions { margin-left: auto; display: flex; gap: 6px; }
.bc-dev-head-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bc-dev-name { font-weight: 700; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }

.bc-license {
    display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px;
    font-size: 12px; font-weight: 700; background: #EFF4FF; color: var(--primary); white-space: nowrap;
}
.bc-license.soon { background: var(--warn-bg); color: var(--warn-fg); }
.bc-license.imminent { background: var(--danger-bg); color: var(--danger-fg); }

/* 버튼 수가 기기 설정(에러 배출 사용 여부)에 따라 달라지므로 개수만큼 같은 폭으로 나눈다. */
.bc-dev-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin-bottom: 14px; }
.bc-dev-actions .bc-btn { justify-content: center; height: 44px; font-weight: 700; }

.bc-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.bc-card-title { font-weight: 700; font-size: 16px; }

.bc-kv { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid #F1F4F8; font-size: 14px; }
.bc-kv .k { font-weight: 600; color: var(--slate); }
.bc-kv .v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.bc-sum-box {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-top: 10px; padding: 12px 16px; background: #F8FAFC; border-radius: 12px;
}
.bc-sum-box .label { font-weight: 600; color: var(--slate); font-size: 14px; }
.bc-sum-box .value { font-weight: 800; font-size: 20px; }
.bc-sum-box.sub { margin-top: 6px; background: var(--danger-bg); }
.bc-sum-box.sub .label, .bc-sum-box.sub .value { color: var(--danger-fg); font-size: 14px; }
.bc-sum-box.sub .value { font-size: 16px; }

/* 교환 요약표: 권종 × (투입, 배출) */
.bc-ex-grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 14px; }
.bc-ex-grid th, .bc-ex-grid td { padding: 8px 4px; text-align: right; border-bottom: 1px solid #F1F4F8; }
.bc-ex-grid th:first-child, .bc-ex-grid td:first-child { text-align: left; font-weight: 600; color: var(--slate); }
.bc-ex-grid thead th { font-size: 12.5px; color: #7A8699; font-weight: 600; }
.bc-ex-grid td { font-weight: 700; }
.bc-ex-grid td .zero { color: var(--muted2); font-weight: 600; }
.bc-ex-grid td .cnt { display: block; color: var(--muted); font-size: 11.5px; font-weight: 500; }
.bc-ex-grid tfoot th, .bc-ex-grid tfoot td { border-bottom: none; padding-top: 10px; font-size: 15px; font-weight: 800; }
.bc-ex-grid tfoot td.in { color: var(--primary); }

.bc-notice { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--slate); line-height: 1.55; }
.bc-notice-title { font-weight: 800; font-size: 16px; color: var(--ink); }
.bc-notice.danger { background: var(--danger-bg); border-color: #F4D2D2; }
.bc-notice.danger .bc-notice-title { color: var(--danger-fg); }

.bc-form-msg { margin-top: 10px; padding: 10px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; }
.bc-form-msg.ok { background: var(--success-bg); color: var(--success-fg); }
.bc-form-msg.error { background: var(--danger-bg); color: var(--danger-fg); }

.bc-btn-block { width: 100%; justify-content: center; height: 44px; margin-top: 12px; }
.bc-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.bc-date-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.bc-date-bar form { margin: 0; }
.bc-date-bar .bc-input { height: 36px; }
.bc-date-quick { display: flex; gap: 6px; }
.bc-date-quick .bc-btn-sm { height: 36px; }

/* 기록 표 — 날짜 열 없이 시간만, 시간 열은 내용 폭만큼만 */
.bc-table.bc-table-fit { min-width: 0; }
.bc-table .bc-col-time { width: 1%; white-space: nowrap; color: #64748B; }
.bc-table th.num, .bc-table td.num { text-align: right; white-space: nowrap; }
.bc-table th.center, .bc-table td.center { text-align: center; }
.bc-table td.num.warn { color: var(--warn-fg); }
.bc-table tfoot th, .bc-table tfoot td { border-bottom: none; border-top: 1px solid var(--border); background: #F8FAFC; font-size: 14px; font-weight: 800; color: var(--ink); }
.bc-table tfoot td.num.warn { color: var(--warn-fg); }

/* 에러 배출 화면 상단 시제 띠 */
.bc-float-strip { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: baseline; margin-bottom: 14px; }
.bc-float-strip .item { display: flex; align-items: baseline; gap: 8px; }
.bc-float-strip .k { font-size: 13px; font-weight: 600; color: var(--slate); }
.bc-float-strip .v { font-weight: 800; font-variant-numeric: tabular-nums; }
.bc-float-strip .item.total .v { font-size: 20px; }

/* 에러 배출 확인 팝업 */
.bc-confirm-list { margin: 16px 0 0; display: flex; flex-direction: column; gap: 2px; }
.bc-confirm-list > div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid #F1F4F8; }
.bc-confirm-list dt { color: var(--slate); font-weight: 600; font-size: 14px; }
.bc-confirm-list dd { margin: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; }
.bc-confirm-list .emph dd { font-size: 22px; font-weight: 800; color: #D33A3A; }
.bc-confirm-list dd.neg { color: var(--danger-fg); }

/* 관리자 편집 창 안내 문구 */
.bc-hint { margin-top: 8px; font-size: 12.5px; color: var(--slate); line-height: 1.5; }
.bc-hint.private { color: var(--warn-fg); }

@media (max-width: 640px) {
    .bc-compact.bc-container { padding: 12px 12px 28px; }
    .bc-compact .bc-card { padding: 14px; }
    .bc-dev-actions .bc-btn { height: 42px; padding: 0 6px; font-size: 13.5px; }
    .bc-sum-box { padding: 10px 12px; }
    .bc-sum-box .value { font-size: 18px; }
    .bc-float-strip .item.total { flex-basis: 100%; }
}

/* 라이센스 관리 모달 */
.bc-lic-group { margin-top: 16px; }
.bc-lic-label { font-weight: 700; font-size: 14px; margin-bottom: 8px; }
.bc-lic-label .bc-sub { font-weight: 500; margin-left: 4px; }
.bc-lic-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
