/* 리브온 CRM 스타일 — 색·간격은 아래 변수에서 한 번에 바꿉니다. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --blue: #2f5be7;
  --blue-hover: #234bd0;
  --blue-soft: #eef2fe;
  --blue-text: #2448c6;
  --green-soft: #e8f6ef; --green-text: #116343;
  --amber-soft: #fdf3e1; --amber-text: #8a4b00;
  --red-soft: #fcecee; --red-text: #a3283c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, .16);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
h1,h2,h3,p { margin: 0; }
h1 { font-size: clamp(1.45rem, 2.4vw, 1.75rem); font-weight: 750; letter-spacing: -.03em; line-height: 1.3; }
h2 { font-size: 1rem; font-weight: 700; letter-spacing: -.02em; }
h3 { font-size: .95rem; font-weight: 700; }
a { color: var(--blue-text); text-underline-offset: 3px; }
strong { font-weight: 700; }
button,input,select,textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
small { display: block; font-size: .8rem; color: var(--muted); font-weight: 500; }
table,.metric strong,.receipt { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- 틀: 왼쪽 메뉴 + 본문 ---------- */
.layout { min-height: 100vh; display: grid; grid-template-columns: 232px minmax(0, 1fr); }
aside { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 14px 16px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; font-weight: 800; font-size: 1rem; white-space: nowrap; letter-spacing: -.02em; }
.brand small { font-weight: 600; letter-spacing: 0; margin-top: 1px; }
.mark { display: inline-grid; place-items: center; flex: 0 0 32px; height: 32px; border-radius: 9px; background: var(--blue); color: #fff; font-size: 1rem; font-weight: 800; }
nav { display: grid; gap: 2px; margin: 30px 0 20px; }
.nav-item { display: flex; align-items: center; gap: 11px; border: 0; border-radius: var(--radius-sm); text-align: left; padding: 9px 10px; color: var(--text-2); background: transparent; white-space: nowrap; font-size: .9rem; font-weight: 600; transition: background .12s, color .12s; }
.nav-item span { width: 18px; font-size: 1rem; text-align: center; color: #9ca3af; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.current { background: var(--blue-soft); color: var(--blue-text); font-weight: 700; }
.nav-item.current span { color: var(--blue); }
.profile { display: flex; gap: 10px; align-items: center; margin: auto 0 12px; padding: 14px 6px 0; border-top: 1px solid var(--line); font-size: .88rem; min-width: 0; }
.profile > div:last-child { min-width: 0; }
.profile strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; place-items: center; flex: 0 0 34px; height: 34px; border-radius: 50%; color: var(--blue-text); background: var(--blue-soft); font-weight: 800; font-size: .9rem; }
aside > .secondary { width: 100%; }

.top { display: flex; justify-content: space-between; align-items: center; height: 52px; padding: 0 clamp(18px, 3.5vw, 44px); background: var(--surface); color: var(--muted); border-bottom: 1px solid var(--line); font-size: .82rem; }
.top span:first-child { display: inline-flex; align-items: center; gap: 7px; font-weight: 650; color: var(--text-2); }
.top span:first-child::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #22a06b; }
.content { max-width: 1440px; margin: 0 auto; padding: 28px clamp(16px, 3.5vw, 44px) 56px; }
.heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; }
.heading p,.muted { color: var(--muted); margin-top: 4px; font-size: .9rem; }
.month { display: flex; gap: 8px; align-items: center; white-space: nowrap; font-size: .85rem; font-weight: 600; color: var(--text-2); }
.month input { width: auto; }

/* ---------- 카드·패널 ---------- */
.metrics,.overview-grid { display: grid; gap: 14px; margin-bottom: 14px; }
.metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric,.panel,.gate-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric { padding: 18px 20px; overflow-wrap: anywhere; }
.metric span { font-size: .85rem; font-weight: 650; color: var(--muted); }
.metric strong { display: block; margin: 6px 0 4px; font-size: clamp(1.35rem, 2.3vw, 1.85rem); font-weight: 750; letter-spacing: -.03em; color: var(--text); }
.metric.accent { background: #16213d; border-color: #16213d; }
.metric.accent span,.metric.accent small { color: #b9c3dc; }
.metric.accent strong { color: #fff; }
.panel { min-width: 0; overflow: hidden; }
.content > .panel + .panel,.content > .panel + section,.content > section + .panel { margin-top: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 56px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.link-panel,.progress-list { display: grid; gap: 12px; padding: 16px 18px; }
.link-panel p { color: var(--muted); font-size: .88rem; }
.progress-list > div { display: grid; grid-template-columns: 80px minmax(0, 1fr) 46px; gap: 10px; align-items: center; font-size: .87rem; color: var(--text-2); }
.progress-list strong { text-align: right; }
progress { width: 100%; height: 8px; appearance: none; border: 0; border-radius: 99px; overflow: hidden; background: #eef0f3; accent-color: var(--blue); }
progress::-webkit-progress-bar { background: #eef0f3; border-radius: 99px; }
progress::-webkit-progress-value { background: var(--blue); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--blue); border-radius: 99px; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); font-size: .9rem; }
.note { padding: 10px 18px; color: var(--muted); font-size: .8rem; }
.hint { color: var(--muted); font-size: .8rem; font-weight: 500; }
.summary { color: var(--blue-text); font-weight: 700; font-size: .88rem; }
.summary:empty { display: none; }
.error { color: var(--red-text); margin: 8px 0; font-size: .88rem; }

/* ---------- 버튼 ---------- */
.secondary,.primary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 13px; min-height: 36px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-2); font-size: .86rem; font-weight: 650; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s; }
.secondary:hover { background: var(--surface-2); border-color: #b8bec8; }
.primary { color: #fff; border-color: var(--blue); background: var(--blue); }
.primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); }

/* ---------- 표 ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; text-align: left; white-space: nowrap; }
th,td { padding: 11px 16px; vertical-align: middle; }
th { background: var(--surface-2); color: var(--muted); font-size: .78rem; font-weight: 650; border-bottom: 1px solid var(--line); }
td { border-top: 1px solid #eff1f4; color: var(--text-2); }
tbody tr:first-child td { border-top: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover td { background: #fafbfd; }
td strong { color: var(--text); }
td small { white-space: normal; }
td mark { background: #fff0a6; color: inherit; border-radius: 3px; padding: 0 1px; }
.detail { display: block; min-width: 220px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* 마지막 칸(관리 버튼)은 가로 스크롤 중에도 보이게 고정 */
table.cards td:last-child,table.cards th:last-child { position: sticky; right: 0; background: var(--surface); box-shadow: -10px 0 10px -10px rgba(16, 24, 40, .12); }
table.cards th:last-child { background: var(--surface-2); }
table.cards tbody tr:hover td:last-child { background: #fafbfd; }

/* ---------- 상태 배지·필터 ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; background: var(--blue-soft); color: var(--blue-text); padding: 2px 9px; font-size: .78rem; font-weight: 650; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge[data-status="정산 완료"],.badge[data-status="설치 완료"],.badge[data-status="사용 중"],.badge[data-status="판매 중"] { background: var(--green-soft); color: var(--green-text); }
.badge[data-status="취소"] { background: var(--red-soft); color: var(--red-text); }
.badge.warn,.badge[data-status="중지"],.badge[data-status="판매중지"],.badge[data-status="숨김"] { background: var(--amber-soft); color: var(--amber-text); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.toolbar input[type=search] { max-width: 320px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--text-2); padding: 5px 12px; font-size: .83rem; font-weight: 600; transition: background .12s, border-color .12s; }
.chip:hover { background: var(--surface-2); }
.chip b { color: var(--muted); font-weight: 700; }
.chip.current { background: var(--text); border-color: var(--text); color: #fff; }
.chip.current b { color: #c7cbd3; }
.search-row { flex: 1 1 340px; justify-content: flex-end; }
.search-row input[type=search] { flex: 1 1 220px; max-width: 360px; }
.search-row select { width: auto; flex: 0 0 auto; }

/* ---------- 입력 ---------- */
.fields { display: grid; gap: 14px; }
.fields label { display: grid; gap: 6px; font-size: .86rem; font-weight: 650; color: var(--text-2); }
input,select,textarea { width: 100%; min-height: 38px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); padding: 7px 11px; color: var(--text); min-width: 0; transition: border-color .12s, box-shadow .12s; }
input::placeholder,textarea::placeholder { color: #9ca3af; }
input:hover,select:hover,textarea:hover { border-color: #b8bec8; }
input:focus,select:focus,textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 91, 231, .15); }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
textarea { min-height: 92px; resize: vertical; }
input[type=checkbox],input[type=radio] { min-height: 0; accent-color: var(--blue); }
.fields .check { display: flex; gap: 9px; align-items: start; font-weight: 500; }
.check input { width: auto; margin-top: 5px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.file input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file span { display: inline-flex; padding: 9px 14px; border: 1px dashed #aab4c8; border-radius: var(--radius-sm); background: var(--surface-2); font-weight: 650; font-size: .86rem; cursor: pointer; }
.file span:hover { border-color: var(--blue); color: var(--blue-text); }
.file input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- 로그인·주문 접수 화면 ---------- */
.gate { max-width: 460px; margin: clamp(24px, 9vh, 96px) auto; padding: 0 16px; }
.gate-card { padding: clamp(20px, 5vw, 32px); margin-top: 18px; box-shadow: 0 12px 32px rgba(16, 24, 40, .07); }
.gate-card h1 { font-size: 1.4rem; }
.gate-card form { margin-top: 22px; }
.gate-card .form-actions .primary { width: 100%; min-height: 42px; }
.gate-link { display: inline-block; margin-top: 18px; font-size: .88rem; }
.receipt { padding: 18px 0; font-size: 1.28rem; font-weight: 800; }

/* ---------- 대화상자 ---------- */
dialog { width: min(92vw, 520px); max-height: 90vh; border: 0; border-radius: 16px; padding: 22px; color: inherit; background: var(--surface); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(17, 24, 39, .45); }
dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -2px 0 16px; }
dialog header h2 { font-size: 1.08rem; }
dialog.wide { width: min(94vw, 740px); }
dl div { display: grid; grid-template-columns: 84px 1fr; gap: 10px; padding: 5px 0; }
dt { font-weight: 650; color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 14px; margin: 0; min-width: 0; }
legend { padding: 0 6px; font-weight: 700; font-size: .84rem; color: var(--blue-text); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-2 > div,.grid-2 > div > label { display: grid; gap: 6px; font-size: .86rem; font-weight: 650; }
.span-2 { grid-column: 1 / -1; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 4px 14px; margin: 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; font-size: .87rem; }
.facts div { grid-template-columns: 1fr; gap: 0; }
.facts dt { font-weight: 600; font-size: .78rem; }
#toast { position: fixed; bottom: 20px; right: 20px; z-index: 20; max-width: calc(100vw - 40px); border-radius: 10px; background: #111827; color: #fff; padding: 11px 16px; font-size: .9rem; box-shadow: var(--shadow-lg); visibility: hidden; opacity: 0; transform: translateY(6px); transition: opacity .18s, transform .18s, visibility .18s; }
#toast.visible { visibility: visible; opacity: 1; transform: none; }

/* ---------- 공지·프로모션·제휴카드 ---------- */
.notices article { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.notices article:last-child { border-bottom: 0; }
.notices p { margin-top: 6px; white-space: pre-wrap; color: var(--text-2); font-size: .9rem; }
.card-comparison { padding: 0 0 8px; border-top: 1px solid var(--line); }
.card-comparison summary { padding: 13px 18px; cursor: pointer; font-weight: 700; }
.benefit-description { display: inline-block; min-width: 16rem; max-width: 42rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- 수수료표 연동 ---------- */
.sync-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; padding: 18px; }
.sync-grid > div { display: grid; gap: 10px; align-content: start; }
.sheet-form { display: flex; gap: 8px; }
details { font-size: .87rem; color: var(--text-2); }
details summary { cursor: pointer; font-weight: 650; color: var(--blue-text); }
details ol { margin: 8px 0 0; padding-left: 20px; display: grid; gap: 5px; }
.sync-result { border-radius: 10px; padding: 12px 14px; font-size: .87rem; }
.sync-result.ok { background: var(--green-soft); color: var(--green-text); }
.sync-result.bad { background: var(--red-soft); color: var(--red-text); }
.sync-result ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- 노트북 (1280px 이하) ---------- */
@media (max-width: 1280px) {
  .layout { grid-template-columns: 208px minmax(0, 1fr); }
  aside { padding: 20px 10px 14px; }
  .content { padding: 24px 24px 44px; }
  th,td { padding: 10px 12px; }
}
/* ---------- 태블릿 (1024px 이하): 메뉴를 위쪽 가로줄로 ---------- */
@media (max-width: 1024px) {
  .layout { display: block; }
  aside { position: sticky; top: 0; z-index: 5; height: auto; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 10px; padding: 10px 16px 0; border-right: 0; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px); }
  .brand { padding: 0; }
  aside > .secondary { width: auto; min-height: 32px; font-size: .8rem; }
  aside nav { grid-area: 2 / 1 / 3 / -1; display: flex; gap: 2px; overflow-x: auto; margin: 0 -16px; padding: 0 12px; scrollbar-width: none; }
  aside nav::-webkit-scrollbar { display: none; }
  .nav-item { padding: 10px 10px 11px; border-radius: 0; border-bottom: 2px solid transparent; }
  .nav-item.current { background: transparent; border-bottom-color: var(--blue); }
  .nav-item span { display: none; }
  .profile { display: none; }
  .top { display: none; }
  .metrics { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
}
/* ---------- 휴대폰·작은 태블릿 (760px 이하): 표를 카드 형태로 ---------- */
@media (max-width: 760px) {
  :root { font-size: 15px; }
  .content { padding: 18px 14px 40px; }
  .metrics,.overview-grid { grid-template-columns: 1fr; gap: 10px; }
  .metric { padding: 15px 16px; }
  .heading { align-items: stretch; flex-direction: column; gap: 12px; margin-bottom: 16px; }
  .heading .inline { justify-content: space-between; }
  .panel-head { flex-wrap: wrap; min-height: 0; padding: 12px 14px; }
  .toolbar { padding: 12px 14px; }
  .toolbar input[type=search] { max-width: none; }
  .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 0 14px 2px; scrollbar-width: none; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; }
  .search-row { flex-basis: 100%; }
  .search-row input[type=search] { max-width: none; }
  .note { padding: 10px 14px; }
  .table-scroll { overflow: visible; }
  table.cards,table.cards tbody,table.cards tr,table.cards td { display: block; white-space: normal; }
  table.cards thead { display: none; }
  table.cards tr { padding: 12px 14px; border-top: 1px solid var(--line); }
  table.cards tbody tr:first-child { border-top: 0; }
  table.cards tbody tr:hover td { background: transparent; }
  /* 라벨을 왼쪽에 고정해 칸 안의 글자·강조·보조줄이 쪼개지지 않게 */
  table.cards td { position: relative; padding: 4px 0 4px 108px; min-height: 1.6em; border: 0; overflow-wrap: anywhere; }
  table.cards td::before { content: attr(data-label); position: absolute; left: 0; top: 5px; width: 98px; color: var(--muted); font-size: .78rem; font-weight: 600; }
  table.cards td:last-child,table.cards th:last-child { position: relative; box-shadow: none; background: transparent; }
  table.cards td:last-child { margin-top: 6px; }
  .detail { min-width: 0; }
  .sync-grid { grid-template-columns: 1fr; padding: 14px; }
  .sheet-form { flex-direction: column; }
  .grid-2 { grid-template-columns: 1fr; }
  dialog,dialog.wide { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; padding: 16px; }
  .form-actions { position: sticky; bottom: -16px; background: var(--surface); padding: 10px 0; border-top: 1px solid var(--line); }
  .secondary,.primary { min-height: 40px; }
  input,select,textarea { min-height: 42px; font-size: 16px; }
  #toast { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}
@media (max-width: 400px) {
  table.cards td { padding-left: 92px; }
  table.cards td::before { width: 84px; }
  .brand small { display: none; }
}
@media (max-width: 340px) {
  table.cards td { padding-left: 0; }
  table.cards td::before { position: static; display: block; width: auto; }
}
@media print {
  aside,.toolbar,.top,button { display: none !important; }
  .layout { display: block; }
  .metric,.panel { box-shadow: none; }
}

/* 렌탈료표 */
button.link { border: 0; background: none; padding: 0; min-height: 0; color: var(--blue-text); font: inherit; font-weight: 650; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.pb-filters { flex: 1 1 100%; justify-content: flex-start; }
.pb-filters input[type=search] { flex: 1 1 260px; max-width: 360px; }
.pb-filters select { width: auto; max-width: 170px; flex: 0 1 auto; }
/* 렌탈료표는 관리 버튼 칸이 없으므로 마지막 칸을 고정하지 않습니다 */
#pb-list table.cards td:last-child,#pb-list table.cards th:last-child { position: static; box-shadow: none; }
#pb-list td .detail { min-width: 180px; max-width: 320px; white-space: normal; font-size: .8rem; color: var(--muted); }
.pb-more { justify-content: center; padding: 14px; border-top: 1px solid var(--line); }
@media (max-width: 760px) {
  .pb-filters select { flex: 1 1 calc(50% - 8px); max-width: none; }
  .pb-filters input[type=search] { flex-basis: 100%; }
}
@media (min-width: 761px) { #pb-list td:nth-child(5) { min-width: 170px; } #pb-list td:nth-child(5) small,#pb-list td:nth-child(2) small { white-space: normal; } }

.card-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; padding: 16px; }
.card-gallery figure { margin: 0; min-width: 0; }
.card-gallery figcaption { font-weight: 700; margin-bottom: 8px; }
.card-gallery img { display: block; width: 100%; height: auto; }
