:root {
    --primary: #4f6ef7;
    --primary-soft: #eef1fe;
    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #e5e9f2;
    --text: #2b3245;
    --muted: #8a93a8;
    --ok-bg: #e1f5ee; --ok-fg: #0f6e56;
    --warn-bg: #faece7; --warn-fg: #993c1d;
    --off-bg: #f1f1f4; --off-fg: #5f5e5a;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: 'Pretendard', 'Malgun Gothic', '맑은 고딕', 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
}

h1 { font-size: 20px; margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
label { font-size: 13px; color: var(--muted); }

.btn-primary { background: var(--primary); color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 7px 12px; font-size: 13px; }
.btn-danger { background: #e24b4a; color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 600; }
.btn-danger:hover { filter: brightness(1.07); }
.warn-text { color: #993c1d; }

.fee-link { background: none; border: none; padding: 0; font: inherit; font-weight: 700; color: var(--primary); text-decoration: underline; cursor: pointer; }
.fee-link:hover { color: #16233f; }

.modal-overlay { position: fixed; inset: 0; background: rgba(20, 24, 35, 0.45); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: #fff; border-radius: 14px; padding: 20px 22px; width: 520px; max-width: 92vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,0.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-title { font-weight: 700; font-size: 15px; }
.modal-x { background: none; border: none; font-size: 16px; color: var(--muted); cursor: pointer; padding: 4px; }
.modal-x:hover { color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.mail-body { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-top: 10px; font-size: 13.5px; line-height: 1.6; }
.modal-box.wide { width: 680px; }
.mail-frame { width: 100%; height: 640px; border: 1px solid var(--border); border-radius: 8px; margin-top: 10px; background: #fff; }

/* ── 인증 화면 ─────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 360px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 36px 32px; }
.auth-logo-img { width: 100%; max-width: 240px; height: auto; display: block; margin: 0 auto 14px; }
.auth-sub { text-align: center; color: var(--muted); margin: 4px 0 22px; }
.auth-card form { display: flex; flex-direction: column; gap: 6px; }
.auth-card input { margin-bottom: 8px; }
.auth-card .btn-primary { margin-top: 10px; }
.auth-error { background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.auth-ok { background: var(--ok-bg); color: var(--ok-fg); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.pw-field { position: relative; margin-bottom: 8px; }
.pw-field input { width: 100%; box-sizing: border-box; padding-right: 36px; margin-bottom: 0; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 15px; padding: 6px; opacity: 0.45; line-height: 1; }
.pw-toggle.active { opacity: 1; }
.auth-options { display: flex; justify-content: space-between; align-items: center; margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.auth-options label.chk { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.auth-options input[type="checkbox"] { width: auto; margin: 0; }

/* ── 셸 레이아웃 ───────────────────────── */
.shell { display: flex; height: 100vh; overflow: hidden; }

.sidebar { width: 230px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--border); padding: 18px 12px; overflow-y: auto; }
.logo { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; color: #16233f; padding: 6px 10px 18px; }
.logo .logo-img { width: 100%; max-width: 172px; height: auto; display: block; }
.logo .sub { font-style: normal; font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.nav-group { font-size: 11px; color: var(--muted); padding: 12px 10px 5px; }
.nav-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: none; border: none; border-radius: 9px; padding: 6px 10px; font-size: 14px; color: var(--text); }
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; }

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

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--border); }
.topbar .date { font-size: 12px; color: var(--muted); margin-top: 3px; }
.user { display: flex; align-items: center; gap: 10px; }
.session-box { display: flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 20px; }
.session-box .sess-timer { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; min-width: 58px; }
.session-box .sess-clock { font-size: 13px; }
.session-box .sess-select { font-size: 12px; padding: 3px 6px; border-radius: 14px; border: 1px solid var(--border); background: #fff; }
.session-box.warn { background: var(--warn-bg); border-color: #f0997b; }
.session-box.warn .sess-timer { color: #993c1d; }
.session-box .sess-disable { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); white-space: nowrap; cursor: pointer; padding-left: 4px; border-left: 1px solid var(--border); margin-left: 2px; }
.session-box .sess-disable input { width: auto; margin: 0; }
.user .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.bell-btn { position: relative; background: none; border: none; font-size: 18px; padding: 6px; border-radius: 50%; line-height: 1; }
.bell-btn:hover { background: var(--bg); }
.bell-badge { position: absolute; top: -2px; right: -2px; background: #e24b4a; color: #fff; font-size: 10px; font-weight: 700; line-height: 1; border-radius: 10px; padding: 3px 5px; min-width: 16px; text-align: center; }
.user .uname { font-weight: 600; }

.wsbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 24px; background: var(--bg); }
.ws-label { font-size: 13px; color: var(--muted); }
.ws-label .count { color: var(--primary); background: var(--primary-soft); border-radius: 10px; padding: 1px 9px; margin-left: 4px; }

.tabstrip { display: flex; gap: 2px; padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab { display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; color: var(--muted); background: transparent; border: 1px solid transparent; border-bottom: none; border-radius: 9px 9px 0 0; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--card); color: var(--text); font-weight: 600; border-color: var(--border); box-shadow: 0 2px 0 0 var(--card); }
.tab-close { color: var(--muted); padding: 0 2px; border-radius: 4px; }
.tab-close:hover { color: #d85a30; background: var(--warn-bg); }

.content { flex: 1; overflow-y: auto; padding: 20px 24px; background: var(--card); }
.empty { color: var(--muted); text-align: center; padding: 80px 0; }
.loading { color: var(--muted); padding: 30px 0; }

/* ── 패널·테이블·컴포넌트 ─────────────── */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 16px; }
.panel-title { font-weight: 700; margin-bottom: 12px; }
.panel-toggle { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: none; padding: 0; text-align: left; cursor: pointer; color: inherit; font-size: inherit; }
.panel-toggle .chevron { display: inline-block; font-size: 11px; color: var(--muted); transition: transform 0.15s ease; }
.panel-toggle .chevron.open { transform: rotate(90deg); }
.form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.hint { font-size: 13px; color: var(--muted); margin: 8px 0; line-height: 1.6; }

table.grid { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
table.grid th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; background: var(--bg); padding: 6px 10px; border-bottom: 1px solid var(--border); }
table.grid td { padding: 6px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
table.grid tr:hover td { background: #fafbfe; }
table.grid tr.row-current td { background: var(--primary-soft); }
table.grid td.fee { font-weight: 700; }
table.grid td.cell-clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid td.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--text); }
th.sortable .sort-arrow { margin-left: 4px; font-size: 10px; color: var(--primary); }

table.dnd-table th.drag-col, table.dnd-table td.drag-col { width: 28px; padding-left: 6px; padding-right: 0; }
table.dnd-table tr[draggable="true"] { cursor: grab; }
table.dnd-table .drag-handle { color: var(--muted); font-size: 14px; cursor: grab; }
table.dnd-table tr.dragging { opacity: 0.4; }
table.dnd-table tr.drag-over td { border-top: 2px solid var(--primary); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 12px; padding: 3px 10px; }
.badge.ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge.warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge.off { background: var(--off-bg); color: var(--off-fg); }
.badge.plan { background: var(--primary-soft); color: #3c3489; }
.plan-none { font-size: 12px; color: var(--muted); }

.metric-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 1100px) { .metric-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px) { .metric-grid { grid-template-columns: repeat(2, 1fr); } }
.metric {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(20, 25, 40, 0.05);
    transition: box-shadow .15s ease, transform .15s ease;
}
.metric:hover { box-shadow: 0 6px 16px rgba(20, 25, 40, 0.09); transform: translateY(-1px); }
.metric.accent { border-color: var(--primary); }
.metric.ok { border-color: var(--ok-fg); }
.metric.warn { border-color: var(--warn-fg); }
.m-top { display: flex; align-items: center; gap: 10px; }
.m-icon-badge {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: var(--off-bg);
}
.metric.accent .m-icon-badge { background: var(--primary-soft); }
.metric.ok .m-icon-badge { background: var(--ok-bg); }
.metric.warn .m-icon-badge { background: var(--warn-bg); }
.accent-text { color: var(--warn-fg); font-weight: 600; }
.ok-text { color: var(--ok-fg); }
.m-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.m-value { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
.m-value .unit { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 3px; }

.plan-grid { display: grid; grid-template-columns: repeat(2, minmax(200px, 340px)); gap: 10px 24px; margin: 10px 0 16px; }
.plan-field { display: flex; flex-direction: column; gap: 5px; }
.plan-field.full { grid-column: 1 / -1; max-width: 340px; margin-top: 16px; }
.plan-section-title { font-size: 13px; font-weight: 700; color: var(--text); margin: 16px 0 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.plan-section-title:first-of-type { border-top: none; padding-top: 0; }
.plan-field.readonly input { background: var(--bg); color: var(--muted); }
.tax-missing { color: #d92d20; font-weight: 700; font-size: 13px; margin-left: 4px; }

.notice-toggle-cols { display: flex; gap: 32px; flex-wrap: wrap; }
.notice-toggle-col { flex: 1 1 0; min-width: 220px; }
.notice-toggle-col-divider { border-left: 1px solid var(--border); padding-left: 32px; }
.notice-toggle-row { display: flex; align-items: center; gap: 28px; padding: 6px 0; flex-wrap: wrap; }
.notice-body-field { display: flex; flex-direction: column; gap: 5px; margin-top: 16px; width: 100%; }
.notice-editor { width: 100%; background: #fff; border-radius: 8px; }
.notice-editor .ql-toolbar.ql-snow { border-color: var(--border); border-radius: 8px 8px 0 0; }
.notice-editor .ql-container.ql-snow { border-color: var(--border); border-radius: 0 0 8px 8px; font-size: 14px; }
.notice-editor .ql-editor { min-height: 240px; }
.notice-save-msg { font-size: 13px; font-weight: 700; color: #16a34a; }
.notice-save-msg.error { color: #d92d20; }

.live-box { background: var(--bg); border: 1px dashed var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.live-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.live-title { font-weight: 700; }

ol.roadmap { margin: 8px 0; padding-left: 20px; line-height: 2; }

/* ── 고객사 List View ─────────────────── */
.lv-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.lv-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lv-search { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.lv-search input { flex: 1; }
.lv-count { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.lv-count b { color: var(--text); }
.lv-pagesize { display: flex; align-items: center; gap: 4px; }
.lv-pagesize .ps { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; font-size: 13px; color: var(--text); }
.lv-pagesize .ps.active { background: #16233f; color: #fff; border-color: #16233f; font-weight: 600; }

table.lv-table { width: 100%; border-collapse: collapse; }
table.lv-table th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; background: #f7f9fc; padding: 7px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.lv-table th.num { text-align: right; }
table.lv-table th.chk-col, table.lv-table td.chk-col { width: 36px; text-align: center; }
table.lv-table th.sortable { cursor: pointer; user-select: none; }
table.lv-table th.sortable:hover { color: var(--text); }
table.lv-table td { padding: 7px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
table.lv-table td.num { text-align: right; }
table.lv-table td.name { font-weight: 600; color: var(--primary); }
table.lv-table tr.clickable { cursor: pointer; }
table.lv-table tr.clickable:hover td { background: #fafbfe; }
.lv-empty { text-align: center; color: var(--muted); padding: 40px 0 !important; }

.pager { display: flex; justify-content: center; gap: 4px; margin-top: 16px; }
.pager .pg { min-width: 34px; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 13px; color: var(--text); }
.pager .pg:hover:not(:disabled) { background: var(--bg); }
.pager .pg:disabled { color: #c5cad6; cursor: default; }
.pager .pg.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

.add-box { background: var(--bg); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.add-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin-bottom: 10px; }
.customer-picker { position: relative; }
.customer-picker input { width: 100%; }
.customer-picker-list { position: absolute; z-index: 20; top: calc(100% + 2px); left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,0.12); max-height: 200px; overflow-y: auto; }
.customer-picker-item { padding: 8px 12px; font-size: 13px; cursor: pointer; }
.customer-picker-item:hover { background: var(--bg); }
.customer-picker-empty { padding: 8px 12px; font-size: 13px; color: var(--muted); }
.customer-picked { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.add-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }

.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.detail-title { font-size: 18px; font-weight: 700; }

table.kv { width: 100%; border-collapse: collapse; margin: 6px 0 12px; }
table.kv th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 4px 10px 4px 0; width: 90px; white-space: nowrap; vertical-align: middle; }
table.kv td { padding: 4px 12px 4px 0; }
table.kv td input { width: 160px; }

/* ── Blazor 오류 UI ───────────────────── */
#blazor-error-ui {
    background: #fff3cd;
    bottom: 0;
    box-shadow: 0 -1px 3px rgba(0,0,0,.2);
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ── 고객사 상세 폼 (회원정보 / 세금계산서) ── */
table.form-tbl { width: 100%; border-collapse: collapse; }
table.form-tbl th { text-align: left; font-size: 14px; color: var(--text); font-weight: 600; background: #f7f9fc; padding: 4px 16px; width: 150px; white-space: nowrap; vertical-align: middle; border-bottom: 1px solid var(--border); }
table.form-tbl td { padding: 4px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.form-tbl input { width: 240px; }
table.form-tbl input.w-full { width: 100%; max-width: 460px; }
table.form-tbl input.mt6 { margin-top: 6px; }
table.form-tbl label.chk { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap; }
table.form-tbl label.chk input[type="checkbox"] { width: auto; margin: 0; }
table.form-tbl td .chk + .chk { margin-left: 18px; }

.addr-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.addr-row input { flex: 1; }
.addr-btn { flex-shrink: 0; white-space: nowrap; }

.biz-split { display: inline-flex; align-items: center; gap: 8px; }
.biz-split .biz-part { width: 80px; text-align: center; }
.biz-split .biz-part-lg { width: 110px; }
.biz-split .dash { color: var(--muted); }

.save-bar { display: flex; align-items: center; gap: 10px; }

/* ── 요금 그룹 (요금제 관리) ── */
.bp-layout { display: flex; gap: 16px; align-items: flex-start; }
.bp-list-pane { width: 460px; flex-shrink: 0; }
.bp-detail-pane { flex: 1; min-width: 0; }
.bp-items { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.bp-item { text-align: left; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.bp-item:hover { background: var(--bg); }
.bp-item.active { border-color: var(--primary); background: var(--primary-soft); }
.bp-main { display: flex; align-items: center; gap: 8px; }
.bp-name { font-weight: 700; }
.bp-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.form-row label.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.form-row label.chk input { width: auto; }

/* ── ISAPI 콘솔 ── */
.ex-desc { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 9px 12px; border-radius: 8px; margin: 10px 0; background: var(--primary-soft); color: var(--text); }
.ex-desc.danger { background: var(--warn-bg); color: var(--warn-fg); }
.console-body { display: flex; gap: 14px; margin-top: 4px; }
.console-col { flex: 1 1 0; display: flex; flex-direction: column; min-width: 0; gap: 6px; }
.console-col textarea.console-text { flex: 1 1 auto; min-height: 220px; font-family: monospace; font-size: 12.5px; resize: vertical; }
.console-resp { flex: 1 1 auto; min-height: 220px; overflow: auto; background: #1e2430; color: #d7e0ea; border-radius: 8px; padding: 12px; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; margin: 0; }
