/* ============================================================
   NTT DID 관리자 — 디자인 시스템
   - 폰트: rem 기반(루트 폰트크기로 전체 스케일 / 다크모드 변수)
   - 색상: 전부 CSS 변수 → [data-theme="dark"]로 일괄 전환
   - 글자크기: html[data-fontscale="1..4"] 로 루트 폰트 조절
   ============================================================ */

/* ---- 글자 크기 스케일 (루트 폰트) : 5단계, 체감되는 폭 ---- */
html                          { font-size: 13px; }
html[data-fontscale="1"]      { font-size: 11.5px; }
html[data-fontscale="2"]      { font-size: 13px; }
html[data-fontscale="3"]      { font-size: 15px; }
html[data-fontscale="4"]      { font-size: 17px; }
html[data-fontscale="5"]      { font-size: 19.5px; }

/* ---- 색상 토큰 (라이트) ---- */
:root {
    --bg:            #f6f9ff;
    --surface:       #ffffff;
    --surface-2:     #fbfcff;
    --heading:       #012970;
    --text:          #444b59;
    --text-muted:    #8a94a6;
    --border:        #eceef3;
    --border-strong: #dfe3ec;

    --primary:       #4154f1;
    --primary-dark:  #2f3fd6;
    --primary-soft:  #eceefe;
    --on-primary:    #ffffff;

    --danger:        #e0483c;
    --danger-dark:   #c23a2f;
    --danger-soft:   #fdecea;
    --danger-text:   #c23a2f;

    --ok:            #1f9254;
    --ok-soft:       #e7f6ee;
    --warn:          #b5790a;
    --warn-soft:     #fbf2dc;
    --info-soft:     var(--primary-soft);

    --nav-text:      #4a5468;
    --nav-icon:      #9aa4b8;
    --nav-group:     #b3bccd;
    --table-head-bg: var(--bg);
    --row-hover:     var(--surface-2);
    --badge-off-bg:  #f0f1f4;
    --badge-off-fg:  #5a6373;

    --radius:        10px;
    --radius-sm:     7px;
    --shadow:        0 2px 24px rgba(1,41,112,.07);
    --shadow-sm:     0 1px 4px rgba(1,41,112,.06);
    --focus-ring:    0 0 0 3px rgba(65,84,241,.18);
    --sidebar-w:     250px;
    --topbar-h:      60px;
}

/* ---- 색상 토큰 (다크) ---- */
html[data-theme="dark"] {
    --bg:            #151823;
    --surface:       #1e2230;
    --surface-2:     #242a3a;
    --heading:       #e8ecf8;
    --text:          #c2c9d8;
    --text-muted:    #8b94a8;
    --border:        #2c3342;
    --border-strong: #3a4254;

    --primary:       #6175ff;
    --primary-dark:  #7d8eff;
    --primary-soft:  #283057;
    --on-primary:    #ffffff;

    --danger:        #f4685c;
    --danger-dark:   #ff8579;
    --danger-soft:   #3a2422;
    --danger-text:   #ff9a90;

    --ok:            #43c483;
    --ok-soft:       #1d3a2c;
    --warn:          #e3b24d;
    --warn-soft:     #3a3320;
    --info-soft:     #283057;

    --nav-text:      #b8c0d2;
    --nav-icon:      #7f899e;
    --nav-group:     #687388;
    --table-head-bg: #242a3a;
    --row-hover:     #262d3d;
    --badge-off-bg:  #2c3342;
    --badge-off-fg:  #9aa4b8;

    --shadow:        0 2px 24px rgba(0,0,0,.4);
    --shadow-sm:     0 1px 4px rgba(0,0,0,.3);
    --focus-ring:    0 0 0 3px rgba(97,117,255,.3);
}

* { box-sizing: border-box; }

html, body { height: 100%; }
body {
    margin: 0;
    font-family: "Pretendard", "Segoe UI", "Malgun Gothic", system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    transition: background .2s, color .2s;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { color: var(--heading); }

/* ---------- 레이아웃 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 50;
}
.brand {
    display: flex; align-items: center; gap: 9px;
    padding: 18px 24px;
    font-size: 1.62rem;
    font-weight: 800;
    color: var(--heading);
    letter-spacing: -.2px;
    border-bottom: 1px solid var(--border);
}
.brand::before {
    content: "";
    width: 12px; height: 12px; border-radius: 3px;
    background: linear-gradient(135deg, var(--primary), #6f7bf7);
    box-shadow: 0 2px 6px rgba(65,84,241,.4);
}
/* 브랜드 로고(내 계정에서 업로드, 기본=업체명 텍스트) — 로고면 포인트 사각형(::before) 숨김 */
.brand:has(.brand-logo)::before { display: none; }
.brand-logo { max-height: 40px; max-width: 100%; width: auto; object-fit: contain; display: block; }
.logo-preview-box { margin-bottom: 14px; padding: 12px; border: 1px dashed var(--border); border-radius: 8px; display: inline-block; background: var(--surface); }
.logo-preview { max-height: 60px; max-width: 260px; object-fit: contain; display: block; }
.nav { display: flex; flex-direction: column; padding: 12px 14px; gap: 2px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 14px;
    color: var(--nav-text);
    border-radius: 8px;
    font-weight: 600;
    font-size: 1.04rem;
    transition: background .12s, color .12s;
    white-space: nowrap;
}
.nav-item i { font-size: 1.27rem; color: var(--nav-icon); transition: color .12s; width: 20px; text-align: center; }
.nav-item:hover { background: var(--bg); color: var(--primary); }
.nav-item:hover i { color: var(--primary); }
.nav-item.is-active { background: var(--primary); color: var(--on-primary); box-shadow: 0 4px 12px rgba(65,84,241,.3); }
.nav-item.is-active i { color: var(--on-primary); }
/* 강조 메뉴(유지보수 등) — 눈에 띄게 */
.nav-item.nav-hot:not(.is-active) { background: var(--primary-soft); color: var(--primary-dark); font-weight: 700; }
.nav-item.nav-hot:not(.is-active) i { color: var(--primary); }
.nav-hot-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-left: auto; animation: nav-hot-pulse 2s infinite; }
.nav-item.is-active .nav-hot-dot { background: var(--on-primary); }
@keyframes nav-hot-pulse {
    0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--primary) 45%, transparent); }
    70%  { box-shadow: 0 0 0 6px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}
.nav-group {
    padding: 14px 14px 5px;
    font-size: .85rem; font-weight: 700; letter-spacing: .6px;
    color: var(--nav-group); text-transform: uppercase;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    position: sticky; top: 0; z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: 6px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 700; color: var(--heading); }
.user-role {
    color: var(--primary); font-size: .92rem; font-weight: 600;
    background: var(--primary-soft); padding: 3px 9px; border-radius: 999px;
    white-space: nowrap; /* 좁은 창에서 배지 줄바꿈 방지 */
}
.menu-toggle { display: none; }

.content { padding: 24px 28px; flex: 1; }

/* ---------- 아이콘 버튼 (topbar 도구: 다크모드/폰트/알림) ---------- */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px;
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1.2rem; line-height: 1;
    transition: background .12s, color .12s, border-color .12s;
    position: relative;
}
.icon-btn:hover { background: var(--bg); color: var(--primary); border-color: var(--primary); }
.icon-btn.is-active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.icon-btn.is-disabled { opacity: .4; pointer-events: none; }
.icon-btn .icon-badge {
    position: absolute; top: -5px; right: -5px;
    min-width: 17px; height: 17px; padding: 0 4px;
    background: var(--danger); color: #fff;
    border-radius: 999px; font-size: .8rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--surface);
}

/* ---------- 알림 드롭다운 ---------- */
.notif { position: relative; }
.notif-menu {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 320px; max-width: 86vw;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    z-index: 60; overflow: hidden;
    display: none;
}
.notif.is-open .notif-menu { display: block; }
.notif-head { padding: 12px 15px; border-bottom: 1px solid var(--border); font-weight: 700; color: var(--heading); display: flex; justify-content: space-between; align-items: center; }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-row { display: flex; gap: 10px; padding: 11px 15px; border-bottom: 1px solid var(--border); color: var(--text); }
.notif-row:last-child { border-bottom: none; }
.notif-row:hover { background: var(--bg); }
.notif-row i { font-size: 1.2rem; color: var(--primary); flex-shrink: 0; margin-top: 1px; }
.notif-row .nr-title { font-weight: 600; color: var(--heading); }
.notif-row .nr-meta { font-size: .85rem; color: var(--text-muted); margin-top: 2px; }
.notif-empty { padding: 28px 15px; text-align: center; color: var(--text-muted); }
.notif-foot { padding: 10px 15px; border-top: 1px solid var(--border); text-align: center; }

/* ---------- 페이지 헤더 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 1.69rem; font-weight: 700; margin: 0; }
.section-head { margin-top: 30px; }

/* ---------- 카드 ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
}
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-label { color: var(--text-muted); font-size: 1rem; font-weight: 600; }
.stat-card .stat-value { font-size: 2.31rem; font-weight: 800; color: var(--heading); margin-top: 8px; line-height: 1; }

/* ---------- 버튼 (상황별 표준 변형) ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: var(--primary);
    color: var(--on-primary);
    cursor: pointer;
    font-size: 1.04rem; font-weight: 600; line-height: 1.4;
    font-family: inherit;
    transition: background .12s, box-shadow .12s, transform .04s, border-color .12s, color .12s;
    white-space: nowrap;
}
.btn:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(65,84,241,.25); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
/* 보조(외곽선) */
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--bg); border-color: var(--primary); color: var(--primary); box-shadow: none; }
.btn-ghost.is-active { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
/* 위험 */
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); box-shadow: 0 4px 12px rgba(224,72,60,.25); }
/* 성공 */
.btn-success { background: var(--ok); color: #fff; }
.btn-success:hover { filter: brightness(.94); box-shadow: 0 4px 12px rgba(31,146,84,.25); }
/* 위험 외곽선(텍스트 대비 확보) */
.btn-outline-danger { background: var(--surface); border-color: var(--danger); color: var(--danger-text); }
.btn-outline-danger:hover { background: var(--danger); color: #fff; }
/* 크기 */
.btn-sm { padding: 5px 11px; font-size: .96rem; border-radius: 6px; }
.btn-lg { padding: 12px 22px; font-size: 1.15rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ---------- 테이블 ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table th, .table td { padding: 12px 16px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; color: var(--text); line-height: 1.45; overflow-wrap: break-word; }
.table th { background: var(--table-head-bg); color: var(--text-muted); font-weight: 700; font-size: .92rem; letter-spacing: .2px; white-space: nowrap; }
/* 이름/타이틀성 셀 줄바꿈 금지(사용자 요청): 셀 기본 nowrap — 넘치면 .table-wrap 가로 스크롤.
   본문/디테일 등 내용성 셀만 .cell-wrap 로 예외(줄바꿈 허용). */
.table td { white-space: nowrap; }
.table td.cell-wrap, .table td.empty { white-space: normal; }
.table td.syslog-path { white-space: normal; } /* 경로는 word-break 로 줄바꿈 유지 */
.syslog-q-list, .syslog-q-list code { white-space: normal; }
.table tbody tr { transition: background .1s; }
.table tbody tr:nth-child(even) td { background: var(--row-alt, rgba(128,128,128,.035)); }
.table tbody tr:hover td { background: var(--row-hover); }
.table tr:last-child td { border-bottom: none; }
/* 표 안 일반 링크만 파란색. 버튼(.btn)은 자기 색을 유지해야 글자가 보인다(파랑 위 파랑 방지). */
.table td a:not(.btn) { color: var(--primary); font-weight: 600; }
.table td a:not(.btn):hover { text-decoration: underline; }
/* 숫자 셀(우측 정렬·고정폭 숫자) */
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
/* 시각/IP 등 부가 정보 셀은 줄바꿈 억제 */
.table td.text-muted { white-space: nowrap; }

/* ---------- 뱃지 ---------- */
.badge { display: inline-flex; align-items: center; white-space: nowrap; padding: 4px 11px; border-radius: 999px; font-size: .92rem; font-weight: 700; background: var(--badge-off-bg); color: var(--badge-off-fg); }
.badge-on { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: var(--badge-off-bg); color: var(--badge-off-fg); }
.badge-super { background: var(--primary-soft); color: var(--primary-dark); }
.badge-general { background: var(--badge-off-bg); color: var(--badge-off-fg); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger-text); }

/* 표 안 액션 버튼들은 줄바꿈 없이 한 줄 유지(필요 시 .table-wrap 가로 스크롤) */
.actions-cell { display: flex; gap: 7px; flex-wrap: nowrap; align-items: center; white-space: nowrap; }
.actions-cell .btn { white-space: nowrap; }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-sep { width: 1px; align-self: stretch; min-height: 24px; background: var(--border-strong); margin: 0 4px; }

/* ---------- 검색/정렬/페이징 ---------- */
.list-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
/* 툴바 내부 폼 컨트롤: 전역 width:100% 무력화 → 내용 폭 + 통일 높이(38px) */
.list-toolbar .input,
.list-toolbar .select {
    width: auto;
    height: 38px;
    padding: 0 12px;
    font-size: .98rem;
}
.list-toolbar .select { padding-right: 32px; }
.list-toolbar .btn { height: 38px; padding-top: 0; padding-bottom: 0; font-size: .98rem; }
/* 검색창은 남는 폭을 채우되 과도하게 넓어지지 않게 */
.list-toolbar .list-search { flex: 1 1 220px; min-width: 170px; max-width: 340px; }
.list-toolbar .input[type="date"] { min-width: 138px; }
.list-toolbar .input[type="number"], .list-toolbar .syslog-slow { width: 104px; }
/* 페이지 크기 선택은 오른쪽으로 */
.list-toolbar .list-per { margin-left: auto; }
.sort-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); font-weight: 700; white-space: nowrap; }
.sort-link:hover { color: var(--primary); }
.sort-link.is-sorted { color: var(--primary); }
.sort-ico { font-size: .82rem; opacity: .35; transition: opacity .12s; }
.sort-link:hover .sort-ico { opacity: .7; }
.sort-ico.is-on { opacity: 1; }
.list-pager { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; gap: 12px; flex-wrap: wrap; }
.list-pager .list-total { color: var(--text-muted); font-size: 1rem; }
.list-pager .pager-links { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }
.list-pager .pager-gap { color: var(--text-muted); padding: 0 2px; }
.list-pager .btn-sm { min-width: 32px; justify-content: center; }
/* 페이지 직접 이동 */
.pager-jump { display: inline-flex; align-items: center; gap: 7px; margin: 0; }
.pager-jump .pager-page { color: var(--text-muted); font-size: .92rem; white-space: nowrap; }
.pager-jump-input { width: 64px; text-align: center; padding: 6px 8px; }
/* number input 스피너 정리 */
.pager-jump-input::-webkit-outer-spin-button,
.pager-jump-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- 폼 ---------- */
.form { max-width: 480px; }
.form-wide { max-width: 880px; }
.form-row { margin-bottom: 17px; }
.form-row label { display: block; margin-bottom: 7px; font-weight: 700; color: var(--heading); font-size: 1.04rem; }
.form-row .hint, .hint { color: var(--text-muted); font-size: .92rem; margin-top: 5px; }
.input, .select, textarea.input {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 1.04rem; font-family: inherit;
    background: var(--surface); color: var(--text);
    transition: border-color .12s, box-shadow .12s, background .2s, color .2s;
}
.input::placeholder, textarea.input::placeholder { color: var(--text-muted); }
.input:focus, .select:focus, textarea.input:focus {
    outline: none; border-color: var(--primary);
    box-shadow: var(--focus-ring);
}
/* select 드롭다운 화살표(caret) */
.select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 11px center;
    background-size: 15px;
    padding-right: 34px;
}
.form-actions { display: flex; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.form-sep { border: none; border-top: 1px solid var(--border); margin: 22px 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 26px; }
.form-row-check { display: flex; flex-direction: column; justify-content: center; }
.form-row-check label { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; }
.input-color { height: 42px; padding: 4px; cursor: pointer; }
/* 라디오 버튼 그룹(logo_mode·alarm_on 등) — 타이핑 대신 클릭 선택 */
.radio-group { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--border-strong, #c7cddb); border-radius: 8px; background: var(--surface, #fff); cursor: pointer; font-weight: 500; user-select: none; transition: border-color .12s, background .12s; }
.radio-chip:hover { border-color: var(--primary, #2f6df0); }
.radio-chip:has(input:checked) { border-color: var(--primary, #2f6df0); background: var(--primary-soft, #eaf1ff); color: var(--primary, #2f6df0); font-weight: 700; }
.radio-chip input { accent-color: var(--primary, #2f6df0); margin: 0; }
.section-title { font-size: 1.15rem; font-weight: 700; color: var(--heading); margin: 24px 0 14px; padding-top: 18px; border-top: 1px solid var(--border); }

/* ---------- 알림 박스 ---------- */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 1.04rem; border: 1px solid transparent; }
.alert-error { background: var(--danger-soft); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.alert-success { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.alert-info { background: var(--info-soft); color: var(--primary-dark); border-color: color-mix(in srgb, var(--primary) 30%, transparent); }
.alert-warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }

.empty { padding: 44px; text-align: center; color: var(--text-muted); }

/* ---------- 브레드크럼 ---------- */
.breadcrumb { font-size: 1rem; color: var(--text-muted); margin-bottom: 12px; }
.breadcrumb a { color: var(--primary); font-weight: 600; }
.breadcrumb .sep { margin: 0 7px; color: var(--text-muted); }

/* ---------- 유틸 ---------- */
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.rx-hex { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .86rem; letter-spacing: .5px; color: var(--text-muted); }
/* 수신기 온라인 표시 + 매칭 목록 */
.rcvr-dot { color: var(--badge-off-fg); font-size: .85rem; }
.rcvr-dot.is-on { color: var(--ok); }
.match-list { display: flex; flex-direction: column; gap: 8px; }
.match-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.match-add-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.match-add-form .input { width: auto; min-width: 260px; }
/* 수신 로그 실시간 표시 */
.rx-live { vertical-align: middle; margin-left: 10px; padding: 3px 10px; border-radius: 999px; border: none; cursor: default; font-size: .8rem; font-weight: 700; font-family: inherit; }
.rx-live.is-live { background: var(--ok-soft); color: var(--ok); animation: rx-pulse 1.8s ease-in-out infinite; }
.rx-live.is-new { background: var(--primary-soft); color: var(--primary-dark); cursor: pointer; animation: none; }
@keyframes rx-pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes rx-fresh-fade { from { background: var(--warn-soft); } to { background: transparent; } }
.table tbody tr.rx-fresh td { animation: rx-fresh-fade 2.2s ease-out; }
.text-danger { color: var(--danger-text); font-weight: 700; }

/* ---------- 토글 스위치 ---------- */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0; cursor: pointer;
    background: var(--border-strong); border-radius: 999px; transition: background .18s;
}
.switch .slider::before {
    content: ""; position: absolute; height: 20px; width: 20px; left: 3px; top: 3px;
    background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:disabled + .slider { opacity: .5; cursor: not-allowed; }
.switch input:focus-visible + .slider { box-shadow: var(--focus-ring); }

/* ---------- 매칭 그리드 (업체↔모니터 넣었다 뺐다) ---------- */
.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.match-card {
    display: flex; flex-direction: column; gap: 10px;
    padding: 13px 15px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); transition: border-color .12s, box-shadow .12s;
    margin: 0;
}
.match-card .mc-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; }
.match-card.is-on { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(65,84,241,.1); background: var(--surface-2); }
.match-card .mc-name { font-weight: 700; color: var(--heading); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-card .mc-sub { display: block; font-weight: 500; font-size: .88rem; color: var(--text-muted); }
/* 매칭 업체 바로가기(#75) — 호출 화면/편집 */
.match-card .mc-links { display: flex; gap: 6px; border-top: 1px solid var(--border); padding-top: 9px; }
.match-card .mc-links .btn { flex: 1; justify-content: center; }

/* 모니터 목록: 매칭 업체 수 클릭 팝오버(#75) — 클릭으로 열고 X/바깥클릭으로 닫음 */
.biz-pop { position: relative; display: inline-block; }
.biz-pop-count {
    display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 24px;
    padding: 0 8px; border: none; border-radius: 999px; cursor: pointer;
    background: var(--info-soft, var(--primary-soft)); color: var(--primary);
    font-weight: 700; font-variant-numeric: tabular-nums; font-family: inherit; font-size: .95rem;
}
.biz-pop-count:hover { filter: brightness(.97); }
.biz-pop-menu {
    position: absolute; left: 0; top: calc(100% + 6px); z-index: 60;
    min-width: 320px; padding: 8px; border: 1px solid var(--border-strong); border-radius: 10px;
    background: var(--surface); box-shadow: var(--shadow-lg, 0 10px 30px rgba(0,0,0,.18));
    display: none; white-space: nowrap;
}
.biz-pop.is-open .biz-pop-menu { display: block; }
.biz-pop-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 6px 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); font-weight: 700; color: var(--text-muted); font-size: .9rem; }
.biz-pop-close { border: none; background: transparent; cursor: pointer; color: var(--text-muted); padding: 2px 4px; border-radius: 6px; font-size: 1rem; line-height: 1; }
.biz-pop-close:hover { background: var(--row-hover); color: var(--heading); }
.biz-pop-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; }
.biz-pop-row + .biz-pop-row { border-top: 1px solid var(--border); }
.biz-pop-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-weight: 600; color: var(--heading); }

/* ---------- 확인 모달 (테마 변경 등) ---------- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 120;
    background: rgba(1, 20, 60, .5);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    background: #fff; border-radius: 12px;
    width: 100%; max-width: 420px;
    padding: 22px 24px;
    box-shadow: 0 18px 50px rgba(0,0,0,.28);
}
.modal-title { font-size: 1.1rem; font-weight: 700; color: var(--navy, #012970); display: flex; align-items: center; gap: 8px; }
.modal-title .bi { color: #d9822b; }
.modal-msg { margin: 12px 0 16px; color: var(--text, #333); line-height: 1.55; font-size: .92rem; }
.modal-quiz {
    display: flex; align-items: center; gap: 10px;
    background: #f5f8ff; border: 1px solid #dfe6f5; border-radius: 8px;
    padding: 12px 14px;
}
.modal-quiz-q { font-size: 1.35rem; font-weight: 700; color: var(--navy, #012970); letter-spacing: 1px; }
.modal-quiz-eq { font-size: 1.2rem; color: var(--text-muted, #78829a); }
.modal-quiz-a { width: 90px; text-align: center; font-size: 1.15rem; font-weight: 700; }
.modal-err { color: #c23a2f; font-size: .88rem; margin-top: 8px; }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; justify-content: flex-end; }

/* ---------- 모바일 오버레이 ---------- */
.nav-overlay { display: none; position: fixed; inset: 0; background: rgba(1,20,60,.4); z-index: 45; }

/* ---------- 단독 실행(bare) 레이아웃 ---------- */
.bare-body { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg); margin: 0; }
.bare-topbar {
    height: var(--topbar-h);
    background: var(--surface); box-shadow: var(--shadow-sm);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 22px; position: sticky; top: 0; z-index: 40;
}
.bare-topbar .bare-title { font-weight: 800; color: var(--heading); font-size: 1.15rem; }
.bare-content { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 26px 22px; }

/* ============================================================
   반응형
   ============================================================ */
@media (max-width: 992px) {
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0; height: 100vh;
        transform: translateX(-100%); transition: transform .22s ease;
        box-shadow: 0 0 40px rgba(1,41,112,.18);
    }
    .layout.nav-open .sidebar { transform: translateX(0); }
    .layout.nav-open .nav-overlay { display: block; }
    .menu-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        background: none; border: none; font-size: 1.85rem; color: var(--heading);
        cursor: pointer; line-height: 1; padding: 0; margin-right: 4px;
    }
    .content { padding: 18px 16px; }
    .topbar { padding: 0 16px; }
}

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .user-name { display: none; }
    .content { padding: 14px 12px; }
    .topbar-right { gap: 6px; }
    .icon-btn { width: 34px; height: 34px; }
    /* 모바일 탑바: 타이틀 밀림 방지 — 좌측은 남는 폭에서 말줄임, 우측 보조 정보 축소 */
    .topbar-left { flex: 1; min-width: 0; overflow: hidden; }
    .topbar-left * { white-space: nowrap; }
    .topbar-right { flex-shrink: 0; }
    .topbar-license { font-size: .78rem; }
    .topbar-license .badge { display: none; }   /* (D-357) 배지 숨김 */
    .user-role { writing-mode: initial; font-size: .78rem; padding: 2px 7px; max-width: 64px; overflow: hidden; text-overflow: ellipsis; }
    .topbar .btn { padding: 6px 10px; font-size: .85rem; }
    /* 좁은 화면: 검색창은 한 줄 전체, 페이지크기 선택은 왼쪽 정렬 */
    .list-toolbar .list-search { flex-basis: 100%; max-width: none; }
    .list-toolbar .list-per { margin-left: 0; }
    .table th, .table td { padding: 10px 12px; }
}

/* TTS 음성 관리 페이지 */
.table-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.tts-clip-audio { height: 34px; vertical-align: middle; max-width: 260px; }
.col-check { width: 36px; text-align: center; }

/* 시스템 로그 */
.syslog-slow { max-width: 110px; }
.syslog-path { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; word-break: break-all; max-width: 320px; }
.syslog-q summary { cursor: pointer; white-space: nowrap; }
.syslog-q-list { margin: 8px 0 4px; padding-left: 18px; max-height: 280px; overflow: auto; }
.syslog-q-list li { margin-bottom: 4px; }
.syslog-q-list code { font-size: .85em; word-break: break-all; }
.syslog-q-ms { display: inline-block; min-width: 52px; color: var(--muted, #888); font-variant-numeric: tabular-nums; }
.syslog-err { color: #c0392b; font-size: .85em; margin-top: 4px; white-space: pre-wrap; }

/* 탑바 라이선스 배지(운영자) */
.topbar-license { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; color: inherit; font-size: .9rem; }
.topbar-license .badge { margin-left: 2px; }

/* 업체관리: 모니터/테마 매핑 배지(다중 매핑) */
.biz-mon-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.biz-mon-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 16px; font-size: .98rem; font-weight: 600; text-decoration: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); white-space: nowrap; }
.biz-mon-badge:hover { border-color: var(--primary); }
.biz-mon-theme { font-size: .88rem; font-weight: 700; padding: 2px 8px; border-radius: 10px; color: #fff; background: #8a93a6; }
.biz-mon-badge.th-individual .biz-mon-theme { background: #2f6df0; }
.biz-mon-badge.th-composite  .biz-mon-theme { background: #8e44ad; }
.biz-mon-badge.th-hospital   .biz-mon-theme { background: #0aa876; }
.biz-mon-badge.th-vehicle    .biz-mon-theme { background: #e67e22; }

/* 시스템 로그: 내부/개발 IP 숨김 토글 */
.syslog-nolocal { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 600; color: var(--text); cursor: pointer; }
.syslog-nolocal input { accent-color: var(--primary); }

/* 커스텀 컬러셋 팔레트(탑바) */
.palette { position: relative; }
.palette-menu {
    display: none; position: absolute; left: 0; top: calc(100% + 8px); z-index: 60;
    min-width: 190px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; box-shadow: var(--shadow); padding: 6px;
}
.palette.is-open .palette-menu { display: block; }
.palette-item {
    display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
    background: none; border: none; cursor: pointer; padding: 8px 10px; border-radius: 7px;
    color: var(--text); font-size: .95rem;
}
.palette-item:hover { background: var(--bg); }
.palette-item.is-cur { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.palette-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--border-strong); flex-shrink: 0; }
.palette-dot[data-c="default"] { background: linear-gradient(135deg, #4154f1 50%, #f6f9ff 50%); }
.palette-manage { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--border); margin-top: 4px; font-size: .88rem; color: var(--text-muted); }
.palette-manage:hover { color: var(--primary); }

/* 컬러셋 관리 페이지 */
.page-actions { display: inline-flex; gap: 8px; align-items: center; }
.uitheme-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .uitheme-layout { grid-template-columns: 1fr; } }
.uitheme-list { display: flex; flex-direction: column; gap: 8px; }
.uitheme-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.uitheme-item.is-editing { border-color: var(--primary); background: var(--primary-soft); }
.uitheme-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.uitheme-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uitheme-meta { font-size: .82rem; color: var(--text-muted); }
.uitheme-item .actions-cell { display: inline-flex; gap: 6px; align-items: center; }
.uitheme-item .actions-cell form { margin: 0; }
.uitheme-swatches { display: inline-flex; gap: 3px; }
.uitheme-swatches i { width: 16px; height: 16px; border-radius: 4px; border: 1px solid var(--border-strong); display: inline-block; }

/* 테마 편집 설정 탭(동작/미디어·문구/색상/음성) */
.te-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.te-tab-btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
    border-radius: 8px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: .95rem;
}
.te-tab-btn:hover { border-color: var(--primary); color: var(--primary); }
.te-tab-btn.is-active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.te-tab-n { font-size: .75rem; opacity: .75; }
.te-tab-panel { display: none; }
.te-tab-panel.is-active { display: grid; }
