:root{
  --bg:#eef1f6;
  --panel:#ffffff;
  --ink:#1c2430;
  --muted:#6b7585;
  --line:#dde2ea;
  --brand:#14b1c4;        /* 폰클 청록(teal) 액센트 */
  --brand-d:#0e94a4;
  --brand-soft:#e2f6f9;
  --nav:#2c3142;          /* 짙은 차콜 좌측 메뉴 (폰클 매니저2 느낌) */
  --nav-2:#383e52;
  --nav-ink:#b9c0cf;
  --good:#0f9d63;
  --good-bg:#e4f6ee;
  --warn:#c98a00;
  --warn-bg:#fbf2dc;
  --bad:#d83a54;
  --bad-bg:#fbe9ed;
  --shadow:0 1px 3px rgba(20,30,70,.05);
  --shadow-lg:0 12px 40px rgba(20,30,70,.18);
  --r:8px;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{
  font-family:"Pretendard","Malgun Gothic","맑은 고딕",system-ui,-apple-system,sans-serif;
  background:var(--bg); color:var(--ink); font-size:14px; line-height:1.5;
}
button{font-family:inherit}
h1,h2,h3,h4{margin:0}
a{color:var(--brand)}

/* ===== 상단바 ===== */
.topbar{
  height:54px; display:flex; align-items:center; gap:12px; padding:0 18px;
  background:var(--panel); border-bottom:1px solid var(--line); position:sticky; top:0; z-index:30;
  box-shadow:0 1px 0 rgba(20,30,70,.03);
}
.brand{display:flex; align-items:center; gap:8px; font-weight:800; font-size:16px; letter-spacing:-.3px}
.logo{font-size:20px}
.topbar-right{margin-left:auto; display:flex; gap:8px; align-items:center}
.menu-btn{display:none; border:0; background:none; font-size:22px; cursor:pointer; color:var(--ink)}

/* ===== 레이아웃 ===== */
.layout{display:flex; min-height:calc(100vh - 54px)}
.sidenav{
  width:208px; background:var(--nav); border-right:1px solid var(--nav);
  padding:12px 10px; display:flex; flex-direction:column; gap:2px; position:sticky; top:54px;
  height:calc(100vh - 54px); flex:0 0 auto;
}
.nav-item{
  display:flex; align-items:center; gap:10px; width:100%; text-align:left;
  padding:10px 12px; border:0; background:none; border-radius:7px; cursor:pointer;
  font-size:13.5px; color:var(--nav-ink); font-weight:600; transition:background .12s,color .12s;
}
.nav-item span{font-size:16px; width:22px; text-align:center; opacity:.95}
.nav-item:hover{background:var(--nav-2); color:#fff}
.nav-item.active{background:var(--brand); color:#fff; box-shadow:0 2px 8px rgba(20,177,196,.4)}
.nav-item.active span{opacity:1}
.nav-spacer{flex:1}
.nav-backdrop{display:none}
.content{flex:1; padding:20px 22px; max-width:1240px; width:100%; margin:0 auto}

/* ===== 페이지 헤더 ===== */
.page-head{display:flex; align-items:center; gap:12px; margin-bottom:16px; flex-wrap:wrap; padding-bottom:14px; border-bottom:1px solid var(--line)}
.page-head h2{font-size:19px; letter-spacing:-.4px}
.page-head .sub{color:var(--muted); font-size:13px}
.page-head .spacer{flex:1}

/* ===== 버튼 ===== */
.btn{
  border:1px solid var(--brand); background:var(--brand); color:#fff; padding:8px 14px;
  border-radius:7px; cursor:pointer; font-weight:600; font-size:13.5px; white-space:nowrap; transition:background .12s,filter .12s;
}
.btn:hover{background:var(--brand-d)}
.btn.ghost{background:#fff; color:var(--ink); border-color:var(--line)}
.btn.ghost:hover{background:#f2f4f8; border-color:#cdd3dd}
.btn.sm{padding:5px 10px; font-size:12.5px}
.btn.danger{background:var(--bad); border-color:var(--bad)}
.btn.danger:hover{filter:brightness(.95)}
.btn.good{background:var(--good); border-color:var(--good)}
.btn-row{display:flex; gap:8px; flex-wrap:wrap}

/* ===== 카드 ===== */
.card{background:var(--panel); border:1px solid var(--line); border-radius:var(--r); box-shadow:var(--shadow)}
.card.pad{padding:16px}

/* ===== 통계 카드 (KPI 타일) ===== */
.stat-grid{display:grid; grid-template-columns:repeat(auto-fit,minmax(165px,1fr)); gap:12px; margin-bottom:18px}
.stat{background:var(--panel); border:1px solid var(--line); border-left:3px solid var(--brand); border-radius:var(--r); padding:13px 15px; box-shadow:var(--shadow)}
.stat .label{color:var(--muted); font-size:12.5px; margin-bottom:5px; font-weight:600}
.stat .value{font-size:22px; font-weight:800; letter-spacing:-.6px}
.stat .value.good{color:var(--good)}
.stat .value.bad{color:var(--bad)}
.stat .value.warn{color:var(--warn)}
.stat .foot{font-size:12px; color:var(--muted); margin-top:3px}

/* ===== 테이블 (고밀도) ===== */
.table-wrap{overflow-x:auto; background:var(--panel); border:1px solid var(--line); border-radius:var(--r); box-shadow:var(--shadow)}
table{width:100%; border-collapse:collapse; font-size:13px}
thead th{
  text-align:left; padding:9px 13px; background:#eef1f7; color:#4a5466;
  font-weight:700; border-bottom:1px solid var(--line); white-space:nowrap; font-size:12px; letter-spacing:-.2px;
}
tbody td{padding:8px 13px; border-bottom:1px solid #eceff3; white-space:nowrap}
tbody tr:nth-child(even){background:#fafbfd}
tbody tr:last-child td{border-bottom:0}
tbody tr:hover{background:var(--brand-soft)}
td.num,th.num{text-align:right; font-variant-numeric:tabular-nums}
.row-actions{display:flex; gap:6px}
.empty{padding:38px 16px; text-align:center; color:var(--muted)}

/* ===== 뱃지 ===== */
.badge{display:inline-block; padding:2px 8px; border-radius:5px; font-size:11.5px; font-weight:700}
.badge.good{background:var(--good-bg); color:var(--good)}
.badge.warn{background:var(--warn-bg); color:var(--warn)}
.badge.bad{background:var(--bad-bg); color:var(--bad)}
.badge.gray{background:#eceef3; color:var(--muted)}

/* ===== 폼 ===== */
.form-grid{display:grid; grid-template-columns:repeat(2,1fr); gap:12px}
.form-grid .full{grid-column:1/-1}
.field{display:flex; flex-direction:column; gap:5px}
.field label{font-size:12.5px; font-weight:600; color:#525b6b}
.field input,.field select,.field textarea{
  padding:9px 11px; border:1px solid var(--line); border-radius:7px; font-size:14px; font-family:inherit; background:#fff; color:var(--ink);
}
.field input:focus,.field select:focus,.field textarea:focus{outline:2px solid #b9e8ef; border-color:var(--brand)}
.field textarea{resize:vertical; min-height:64px}
.field .hint{font-size:12px; color:var(--muted)}
.toolbar{display:flex; gap:9px; flex-wrap:wrap; align-items:center; margin-bottom:14px}
.toolbar input[type=search],.toolbar select{padding:8px 11px; border:1px solid var(--line); border-radius:7px; font-size:13.5px; background:#fff}
.toolbar .spacer{flex:1}

/* 정산 계산 박스 */
.calc-box{background:#f6f8fc; border:1px solid var(--line); border-radius:var(--r); padding:14px}
.calc-line{display:flex; justify-content:space-between; padding:5px 0; font-size:14px}
.calc-line.plus span:last-child{color:var(--good); font-weight:600}
.calc-line.minus span:last-child{color:var(--bad); font-weight:600}
.calc-total{display:flex; justify-content:space-between; border-top:2px solid var(--line); margin-top:6px; padding-top:10px; font-size:16.5px; font-weight:800}
.calc-total .pos{color:var(--good)} .calc-total .neg{color:var(--bad)}

/* 사진 첨부 */
.photo-strip{display:flex; gap:10px; flex-wrap:wrap; margin-top:8px}
.photo-thumb{position:relative; width:84px; height:84px; border-radius:8px; overflow:hidden; border:1px solid var(--line); cursor:pointer; background:#f3f4f6}
.photo-thumb img{width:100%; height:100%; object-fit:cover}
.photo-thumb .del{position:absolute; top:2px; right:2px; background:rgba(0,0,0,.6); color:#fff; border:0; border-radius:50%; width:20px; height:20px; cursor:pointer; font-size:13px; line-height:1}
.photo-add{width:84px; height:84px; border:2px dashed var(--line); border-radius:8px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; cursor:pointer; color:var(--muted); font-size:12px; background:#fff}
.photo-add:hover{border-color:var(--brand); color:var(--brand)}
.photo-add .ic{font-size:22px}

/* ===== 모달 ===== */
.modal{position:fixed; inset:0; background:rgba(17,24,39,.5); display:flex; align-items:flex-start; justify-content:center; z-index:50; padding:24px; overflow-y:auto}
.modal-box{background:var(--panel); border-radius:12px; width:100%; max-width:680px; box-shadow:var(--shadow-lg); margin:auto}
.modal-head{display:flex; align-items:center; padding:15px 20px; border-bottom:1px solid var(--line)}
.modal-head h3{font-size:16.5px; letter-spacing:-.3px}
.modal-close{margin-left:auto; border:0; background:none; font-size:26px; cursor:pointer; color:var(--muted); line-height:1}
.modal-body{padding:20px}
.modal-foot{display:flex; gap:10px; justify-content:flex-end; margin-top:20px}

/* 이미지 뷰어 */
.viewer{position:fixed; inset:0; background:rgba(0,0,0,.88); display:flex; align-items:center; justify-content:center; z-index:60; padding:24px}
.viewer img{max-width:100%; max-height:100%; border-radius:8px}
.viewer-close{position:absolute; top:16px; right:20px; background:none; border:0; color:#fff; font-size:40px; cursor:pointer}

/* 토스트 */
.toast{position:fixed; bottom:24px; left:50%; transform:translateX(-50%) translateY(20px); background:#111827; color:#fff; padding:12px 20px; border-radius:9px; font-weight:600; opacity:0; pointer-events:none; transition:.25s; z-index:80; box-shadow:var(--shadow-lg)}
.toast.show{opacity:1; transform:translateX(-50%) translateY(0)}
.toast.bad{background:var(--bad)} .toast.good{background:var(--good)}

.hidden{display:none !important}

/* 로그인 오버레이 */
.auth-overlay{position:fixed; inset:0; background:var(--bg); display:flex; align-items:center; justify-content:center; z-index:100; padding:20px}
.auth-card{background:var(--panel); border:1px solid var(--line); border-radius:14px; box-shadow:var(--shadow-lg); width:100%; max-width:380px; padding:28px}
.auth-card h2{font-size:19px; margin-bottom:6px}
.auth-card .sub{color:var(--muted); font-size:13px; margin-bottom:18px; line-height:1.5}
.auth-card .field{margin-bottom:12px}
.auth-msg{margin-top:12px; font-size:13px; min-height:18px; line-height:1.5}

.section-title{font-size:13.5px; font-weight:700; margin:18px 0 10px; color:#3a4456; display:flex; align-items:center; gap:8px}
/* 접이식 섹션 (개통폼 간소화) */
details.sec-fold{margin:0}
details.sec-fold>summary.section-title{cursor:pointer; list-style:none; user-select:none; padding:8px 0}
details.sec-fold>summary.section-title::-webkit-details-marker{display:none}
details.sec-fold>summary.section-title::before{content:'▸'; color:var(--brand); font-size:11px; transition:transform .15s}
details.sec-fold[open]>summary.section-title::before{transform:rotate(90deg)}
.fold-hint{font-size:11.5px; font-weight:500; color:var(--muted)}
details.sec-fold[open] .fold-hint{display:none}
.muted{color:var(--muted)}
.right{text-align:right}

/* 자동계산 결과 강조 칸 (폰클식: 정산금액·실판매마진 인라인) */
.field input.result{background:#fff8e6; border-color:#f0d98a; font-weight:800; font-size:16px; color:#1c2430; letter-spacing:-.3px}
.field input.result.neg{background:#fdebee; border-color:#f3c0ca; color:var(--bad)}

/* ===== 요금설계 (레인보우 스타일: 주황 액센트) ===== */
.carrier-tabs{display:flex; gap:6px; flex-wrap:wrap; margin-bottom:6px}
.carrier-tab{padding:9px 20px; border:1px solid var(--line); border-radius:8px 8px 0 0; background:#fff; cursor:pointer; font-weight:700; font-size:14px; color:var(--muted); transition:.12s}
.carrier-tab.active{background:#f47b20; border-color:#f47b20; color:#fff; box-shadow:0 2px 8px rgba(244,123,32,.3)}
.carrier-tab:hover:not(.active){background:#fff5ec; color:#f47b20; border-color:#f6c79a}
.est-bar{display:flex; align-items:center; gap:10px; background:#fff; border:1px solid var(--line); border-left:4px solid #f47b20; border-radius:var(--r); padding:11px 16px; margin:16px 0 10px; font-weight:800; color:#2a2f3a; font-size:15px}
.est-bar .tag{font-size:12px; font-weight:600; color:var(--muted)}

/* ===== 모델/요금제 선택 팝업 (레인보우 스타일) ===== */
.picker-overlay{position:fixed; inset:0; background:rgba(17,24,39,.45); display:flex; align-items:flex-start; justify-content:center; z-index:75; padding:24px; overflow-y:auto}
.picker-box{background:#fff; border-radius:12px; width:100%; max-width:720px; box-shadow:var(--shadow-lg); margin:auto; display:flex; flex-direction:column; max-height:88vh}
.picker-head{display:flex; align-items:center; padding:14px 18px; border-bottom:1px solid var(--line)}
.picker-head h3{font-size:16px; letter-spacing:-.3px}
.picker-head .x{margin-left:auto; border:0; background:none; font-size:24px; cursor:pointer; color:var(--muted); line-height:1}
.picker-body{padding:14px 18px; overflow-y:auto}
.picker-search{width:100%; padding:9px 12px; border:1px solid var(--line); border-radius:7px; margin-bottom:10px; font-size:14px}
.picker-tabs{display:flex; flex-wrap:wrap; gap:6px; margin-bottom:10px}
.picker-tab{padding:7px 13px; border:1px solid var(--line); border-radius:7px; background:#fff; cursor:pointer; font-weight:600; font-size:13px; color:var(--muted); white-space:nowrap}
.picker-tab.active{background:#f47b20; border-color:#f47b20; color:#fff}
.picker-tab:hover:not(.active){background:#fff5ec; color:#f47b20}
.picker-table-wrap{border:1px solid var(--line); border-radius:8px; overflow:hidden}
.picker-table{width:100%; border-collapse:collapse; font-size:13.5px}
.picker-table th{text-align:left; padding:9px 12px; background:#f1f3f8; color:#4a5466; font-weight:700; font-size:12.5px}
.picker-table td{padding:9px 12px; border-bottom:1px solid #eef0f4; white-space:nowrap}
.picker-table tbody tr{cursor:pointer}
.picker-table tbody tr:last-child td{border-bottom:0}
.picker-table tbody tr:hover{background:#fff5ec}

/* ===== 반응형 ===== */
@media (max-width:820px){
  .menu-btn{display:block}
  .sidenav{position:fixed; left:0; top:54px; z-index:40; transform:translateX(-100%); transition:.25s; box-shadow:var(--shadow-lg)}
  .sidenav.open{transform:translateX(0)}
  .nav-backdrop.show{display:block; position:fixed; inset:54px 0 0 0; background:rgba(0,0,0,.35); z-index:35}
  .content{padding:14px}
  .form-grid{grid-template-columns:1fr}
  .brand-name{font-size:14px}
}
