/* 관리자 전용 AI 잔액 배지 — .aib-* 범위에만 적용 */
.aib-root { position: relative; flex: 0 0 auto; }

.aib-badge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 10px 0 8px;
    border-radius: 15px; border: 1px solid var(--border-color);
    background: var(--card-bg); color: var(--text-primary);
    font: inherit; font-size: .85rem; line-height: 1; white-space: nowrap;
    cursor: pointer; box-shadow: var(--shadow-sm); transition: var(--transition);
    position: relative;
}
.aib-badge:hover { background: var(--hover-bg); }
.aib-badge:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.aib-root.is-open .aib-badge { background: var(--hover-bg); }

.aib-badge-label {
    font-size: .68rem; font-weight: 800; letter-spacing: .04em;
    padding: 3px 5px; border-radius: 6px;
    background: color-mix(in srgb, #10a37f 22%, transparent); color: #1fa883;
}
.aib-badge-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.aib-badge-tag { font-size: .66rem; color: var(--text-secondary); }
/* 넓은 화면: [AI] 금액 확인값 한 줄 — 묶음을 풀고 순서로 배치 */
.aib-badge-id { display: contents; }
.aib-badge-label { order: 0; }
.aib-badge-amount { order: 1; }
.aib-badge-tag { order: 2; }

/* 상태 점: 오래됨=노랑, 오류=빨강 */
.aib-badge-dot { display: none; width: 7px; height: 7px; border-radius: 50%; position: absolute; top: -2px; right: -2px; border: 1.5px solid var(--card-bg); }
.aib-root[data-status="stale"] .aib-badge-dot { display: block; background: #fbbc04; }
.aib-root[data-status="error"] .aib-badge-dot { display: block; background: #f28b82; }
.aib-root[data-status="loading"] .aib-badge-amount,
.aib-root[data-status="empty"] .aib-badge-amount { color: var(--text-secondary); font-weight: 600; }

/* 팝오버 */
.aib-pop {
    position: absolute; top: calc(100% + 8px); right: 0; z-index: 210;
    width: 290px; max-width: calc(100vw - 24px); box-sizing: border-box;
    padding: 14px; display: flex; flex-direction: column; gap: 10px;
    background: var(--card-bg); color: var(--text-primary);
    border: 1px solid var(--border-color); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md); font-size: .85rem; text-align: left;
}
.aib-pop[hidden] { display: none; }
.aib-pop-head { display: flex; align-items: center; justify-content: space-between; }
.aib-pop-title { font-weight: 800; font-size: .9rem; }
.aib-close {
    width: 26px; height: 26px; border-radius: 50%; border: none; background: none;
    color: var(--text-secondary); font-size: 1.1rem; line-height: 1; cursor: pointer;
}
.aib-close:hover { background: var(--hover-bg); color: var(--text-primary); }
.aib-close:focus-visible { outline: 2px solid var(--accent-color); }

.aib-summary { padding: 10px 12px; border-radius: var(--radius-md); background: var(--hover-bg); }
.aib-sum-amount { font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.aib-sum-meta { margin-top: 2px; font-size: .75rem; color: var(--text-secondary); }
.aib-root[data-status="stale"] .aib-sum-meta { color: #d39e00; }

.aib-notice { margin: 0; font-size: .74rem; line-height: 1.45; color: var(--text-secondary); }

.aib-link {
    display: block; text-align: center; padding: 7px 10px;
    border-radius: var(--radius-md); border: 1px solid var(--border-color);
    color: var(--accent-color); font-weight: 700; text-decoration: none;
}
.aib-link:hover { background: var(--hover-bg); }
.aib-link:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; }

.aib-form { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.aib-label { font-size: .75rem; font-weight: 700; color: var(--text-secondary); }
.aib-row { display: flex; gap: 6px; }
.aib-input-wrap {
    flex: 1; min-width: 0; display: flex; align-items: center;
    border: 1px solid var(--border-color); border-radius: 8px; background: var(--bg-color);
}
.aib-input-wrap:focus-within { border-color: var(--accent-color); }
.aib-prefix { padding-left: 9px; color: var(--text-secondary); font-weight: 700; }
.aib-input {
    flex: 1; min-width: 0; padding: 7px 8px 7px 4px;
    border: none; outline: none; background: transparent;
    color: var(--text-primary); font: inherit; font-variant-numeric: tabular-nums;
}
.aib-input:disabled { opacity: .6; }
.aib-save {
    flex: 0 0 auto; padding: 0 14px; border: none; border-radius: 8px;
    background: var(--accent-color); color: var(--accent-text);
    font: inherit; font-weight: 700; cursor: pointer;
}
[data-theme="light"] .aib-save { color: #041e49; }
.aib-save:hover:not(:disabled) { background: var(--accent-hover); }
.aib-save:disabled { opacity: .6; cursor: default; }
.aib-save:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 1px; }

.aib-msg { min-height: 1.1em; font-size: .75rem; color: var(--text-secondary); }
.aib-msg:empty { min-height: 0; }
.aib-msg[data-tone="error"] { color: #f28b82; }
.aib-msg[data-tone="ok"] { color: #10a37f; }
.aib-msg[data-tone="warn"] { color: #d39e00; }

/* ── 반응형 ──────────────────────────────────
   어느 너비에서도 'AI'와 '확인값'은 숨기지 않는다 (무슨 잔액인지·자동조회 아님을 알려야 하므로).
   기준 치수(index.html/styles.css): 768px 이하에서 햄버거 버튼이 left 24px·폭 약 40px(→ 64px까지),
   .notif-area 는 right 24px, 마일리지 알약 약 110px + 벨 40px + gap 10px×2. */

/* 560px 이하: AI/확인값을 금액 왼쪽에 두 줄로 쌓아 폭을 줄인다 (약 100px) */
@media (max-width: 560px) {
    .aib-badge { gap: 5px; padding: 0 8px 0 5px; }
    .aib-badge-id { display: inline-flex; flex-direction: column; align-items: center; gap: 1px; order: 0; line-height: 1; }
    .aib-badge-label { font-size: .6rem; padding: 1px 4px; border-radius: 4px; }
    .aib-badge-tag { font-size: .56rem; letter-spacing: -.02em; }
    .aib-badge-amount { order: 1; font-size: .82rem; }
    /* 배지가 화면 가운데쯤이라 absolute 팝오버는 왼쪽이 잘림 → 화면 기준 고정 */
    .aib-pop { position: fixed; top: 72px; left: 12px; right: 12px; width: auto; max-width: none; }
}

/* 380px 이하(320·360): 햄버거 버튼과 마일리지 사이에 자리가 없음 →
   배지를 마일리지·벨 줄 바로 아래 오른쪽 정렬 두 번째 줄로 내린다 (한 줄 표기 유지) */
@media (max-width: 380px) {
    .aib-root { position: absolute; top: calc(100% + 6px); right: 0; }
    .aib-badge { height: 26px; gap: 6px; padding: 0 9px 0 6px; }
    .aib-badge-id { display: contents; }
    .aib-badge-label { order: 0; font-size: .62rem; padding: 2px 4px; }
    .aib-badge-amount { order: 1; }
    .aib-badge-tag { order: 2; font-size: .62rem; letter-spacing: 0; }
    .aib-pop { top: 104px; }

    /* 두 번째 줄 배지 아래로 콘텐츠를 내림 — 배지가 붙어 있을 때만(:has) 적용되므로 dispose 시 원래 여백으로 복귀.
       기존 값(!important)을 이기도록 선택자 우선순위를 한 단계 높임.
       일반: 기존 80px, 배지 하단 96px → 106px / 사무실: 기존 82px, 배지 하단 90px → 100px (각 10px 여유) */
    .content-area:has(> .notif-area > .aib-root) { padding-top: 106px !important; }
    .content-area.office-content-active:has(> .notif-area > .aib-root) { padding-top: 100px !important; }
}
