/* ===== 치과 경영자문 회계 솔루션 — 공통 스타일 (prototype/assets/style.css 이식) ===== */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --faint: #9ca3af;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --sidebar: #0f172a;
  --sidebar-2: #1e293b;
  --sidebar-text: #cbd5e1;
  --radius: 10px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ===== Layout shell ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 20px 20px 16px; border-bottom: 1px solid var(--sidebar-2); position: relative; }
.sidebar-close { display: none; }
.sidebar-backdrop { display: none; }
.sidebar .brand .logo { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }
.sidebar .brand .sub { color: #64748b; font-size: 11px; margin-top: 3px; }
.sidebar nav { padding: 8px 10px; overflow-y: auto; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 9px; padding: 8px 12px 8px 20px; border-radius: 8px;
  color: var(--sidebar-text); font-size: 13px; margin-bottom: 1px;
}
.sidebar nav a .ic { width: 14px; text-align: center; opacity: .75; font-size: 12.5px; flex-shrink: 0; }
.sidebar nav a:hover { background: var(--sidebar-2); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar nav a .menu-badge { margin-left: auto; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 20px; display: inline-flex; align-items: center; justify-content: center; }
.sidebar nav a.active .menu-badge { background: #fff; color: var(--accent); }
/* 그룹(1차) 접기/펼치기 — 하위 항목(2차)보다 한 단계 무거운 톤으로 구분 */
.menu-group + .menu-group { margin-top: 2px; }
.menu-group .group-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: none; border: none; cursor: pointer; font-family: inherit;
  color: #94a3b8; font-size: 12.5px; font-weight: 600; letter-spacing: .1px; padding: 14px 12px 8px;
}
.menu-group .group-toggle:hover { color: #e2e8f0; }
.menu-group.open .group-toggle { color: #e2e8f0; }
.menu-group .group-toggle .chev { font-size: 10px; opacity: .7; transition: transform .18s ease; }
.menu-group.open .group-toggle .chev { transform: rotate(180deg); }
.menu-group .group-items { display: grid; grid-template-rows: 0fr; overflow: hidden; transition: grid-template-rows .2s ease; }
.menu-group.open .group-items { grid-template-rows: 1fr; }
.menu-group .group-items-inner { overflow: hidden; min-height: 0; }
.sidebar .foot { padding: 14px 16px; border-top: 1px solid var(--sidebar-2); font-size: 11px; color: #64748b; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; flex-wrap: nowrap; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 20;
}
.menu-toggle { flex-shrink: 0; }
/* 좁아지면 줄바꿈하는 대신 말줄임(...) 처리 — 남는 공간은 role-label/버튼 라벨에 우선 양보 */
.topbar .page-title { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }
.topbar .spacer { flex: 1; min-width: 0; }
.topbar .role-switch { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.topbar select {
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 13px;
  background: var(--surface); color: var(--text); cursor: pointer;
}
.topbar .user { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
/* 역할은 별도 글자 없이 아바타(이니셜 마크)로만 표시 — PC/모바일 공통 */
.topbar .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
/* 상단바 버튼 — 글자를 그대로 유지하고 줄어들지 않게 고정 (좁아지면 대신 페이지 제목이 말줄임 처리됨) */
.topbar-btn { white-space: nowrap; flex-shrink: 0; }
.content { padding: 24px; max-width: 1688px; width: 100%; }

/* ===== Typography ===== */
h1.page-h { font-size: 20px; font-weight: 700; letter-spacing: -0.3px; }
.page-desc { color: var(--muted); margin-top: 4px; font-size: 13px; }
h2.sec { font-size: 15px; font-weight: 600; margin: 4px 0 12px; }
.a-block { margin-top: 28px; }
.a-block > h2.sec { margin-top: 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ===== Cards ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card .card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card .card-head h3 { font-size: 14px; font-weight: 600; }
.card .card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.row { display: flex; gap: 12px; align-items: center; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.mt8{margin-top:8px}.mt16{margin-top:16px}.mt24{margin-top:24px}

/* ===== Stat cards ===== */
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -0.5px; }
.stat .delta { font-size: 12px; margin-top: 4px; }
.stat .delta.up { color: var(--green); }
.stat .delta.down { color: var(--red); }

/* ===== Table =====
 * 규칙: 표는 항상 .table-wrap으로 감싸고, 칸은 기본적으로 줄바꿈하지 않는다(white-space: nowrap).
 * 화면이 좁아지면 칸을 억지로 줄이는 대신(한글이 한 글자씩 줄바꿈되는 문제 발생) .table-wrap이
 * 가로 스크롤을 담당한다. 설명/메모처럼 길게 줄바꿈되어도 괜찮은 칸에는 td에 class="wrap"을 추가한다.
 */
table.tbl { width: 100%; border-collapse: collapse; background: var(--surface); }
table.tbl th, table.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; white-space: nowrap; }
table.tbl th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 12px; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tr:hover td { background: var(--surface-2); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.wrap, table.tbl th.wrap { white-space: normal; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; overflow-y: hidden; }

/* ===== Badges / pills ===== */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500; border: 1px solid transparent; white-space: nowrap; }
.badge.gray { background: #f3f4f6; color: #4b5563; }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #1d4ed8; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost.active { color: var(--accent); background: var(--accent-soft); }
.btn.sm { padding: 5px 10px; font-size: 12px; }

/* ===== Forms ===== */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font-size: 13px; background: var(--surface); color: var(--text); font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .hint, p.hint { font-size: 11.5px; color: var(--faint); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.section-h { font-weight: 600; font-size: 13.5px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }

/* ===== Misc ===== */
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 500; }
.callout { border-radius: 8px; padding: 12px 14px; font-size: 12.5px; border: 1px solid var(--border); background: var(--surface-2); }
.callout.blue { background: var(--accent-soft); border-color: #bfdbfe; color: #1e40af; }
.callout.amber { background: var(--amber-soft); border-color: #fde68a; color: #92400e; }
.callout.green { background: var(--green-soft); border-color: #a7f3d0; color: #065f46; }
.big-amount { font-size: 30px; font-weight: 700; letter-spacing: -1px; }
.breadcrumb { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.breadcrumb a:hover { color: var(--accent); }

/* ===== Tabs ===== */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 20px; overflow-x: auto; }
.tabs .tab { padding: 10px 16px; font-size: 13.5px; font-weight: 500; color: var(--muted); cursor: pointer; border: none; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .tab .cnt { font-size: 11px; background: var(--surface-2); color: var(--muted); border-radius: 20px; padding: 1px 7px; }
.tabs .tab.active .cnt { background: var(--accent-soft); color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Modal ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 640px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-head .x { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; border: none; background: none; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ===== Search ===== */
.search { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; min-width: 240px; background: var(--surface); }
.search:focus { outline: none; border-color: var(--accent); }

/* 읽기전용 표시값 (수정 불가 필드) */
.readonly-val { padding: 9px 11px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; font-size: 13px; color: var(--text); font-weight: 500; }

/* 업무일지 매니저 섹션 */
.wl-sec { margin-bottom: 24px; }
.wl-sec-h { font-weight: 600; font-size: 13.5px; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }

/* 항목별 캡처 이미지 첨부 */
.cap-box { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); }
.cap-h { font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
.dropzone.sm { padding: 14px 16px; font-size: 12.5px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.thumb { position: relative; width: 132px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.thumb img { width: 100%; height: 96px; object-fit: cover; display: block; cursor: zoom-in; }
.thumb .cap-name { font-size: 10.5px; color: var(--muted); padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .rm { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border: none; border-radius: 50%; background: rgba(15,23,42,.65); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.thumb .rm:hover { background: var(--red); }
.chk { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.chk input { width: 16px; height: 16px; }

/* 편집형 테이블 (업무일지 실적 입력) — 가로 스크롤은 .table-wrap 기본 규칙이 처리 */
.edit-tbl td { padding: 5px 8px; vertical-align: middle; }
.edit-tbl input, .edit-tbl select { width: 100%; min-width: 68px; border: 1px solid var(--border); border-radius: 6px; padding: 7px 8px; font-size: 12.5px; background: var(--surface); color: var(--text); font-family: inherit; }
.edit-tbl td.num input { text-align: right; }
.edit-tbl .sumrow td { background: var(--surface-2); font-weight: 600; }
.edit-tbl .fi-x { border: none; background: none; color: var(--muted); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; }
.edit-tbl .fi-x:hover { color: var(--red); }

/* 목록에서 진입 시 해당 행 강조 */
.tbl tr.row-hl > td { background: var(--accent-soft); animation: hlFade 2.4s ease-out; }
@keyframes hlFade { 0% { background: var(--amber-soft); } 100% { background: var(--accent-soft); } }

/* ===== Calendar ===== */
.cal { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--surface-2); }
.cal-head div { padding: 9px 6px; text-align: center; font-size: 12px; color: var(--muted); font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cell { min-height: 104px; border-top: 1px solid var(--border); border-left: 1px solid var(--border); padding: 6px; font-size: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.cal-cell:nth-child(7n+1) { border-left: none; }
.cal-cell.dim { background: var(--surface-2); cursor: default; }
.cal-cell:not(.dim):hover { background: var(--accent-soft); }
.cal-day { font-weight: 600; align-self: flex-start; }
.cal-cell.today .cal-day { background: var(--accent); color: #fff; border-radius: 50%; width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; }
.cal-sun { color: var(--red); }
.cal-sat { color: var(--accent); }
.cal-ev { font-size: 11px; padding: 2px 6px; border-radius: 4px; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-more { font-size: 10.5px; color: var(--muted); padding-left: 2px; }
.cal.compact .cal-cell { min-height: 70px; padding: 4px; }
.cal.compact .cal-ev { font-size: 10px; padding: 1px 4px; }
@media (max-width: 860px) { .cal-cell { min-height: 62px; } .cal-ev { font-size: 9.5px; } }

/* ===== Dropzone (첨부파일) ===== */
.dropzone { border: 2px dashed var(--border); border-radius: 10px; padding: 26px 20px; text-align: center; color: var(--muted); font-size: 13px; transition: all .15s; cursor: pointer; background: var(--surface-2); }
.dropzone:hover { border-color: var(--accent); }
.dropzone.drag { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone .dz-ic { font-size: 26px; display: block; margin-bottom: 8px; }
.filelist { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.fileitem { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--surface); }
.fileitem .fi-ic { color: var(--accent); }
.fileitem .fi-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fileitem .fi-size { color: var(--faint); font-size: 12px; margin-left: auto; white-space: nowrap; }
.fileitem .fi-x { cursor: pointer; color: var(--faint); border: none; background: none; font-size: 16px; line-height: 1; padding: 0 2px; }
.fileitem .fi-x:hover { color: var(--red); }

/* ===== Login ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--sidebar); }
.login-card { background: var(--surface); border-radius: 14px; padding: 36px 34px; width: 360px; }
.login-card .logo { font-size: 18px; font-weight: 700; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 6px 0 24px; }
.login-card .btn.primary { width: 100%; justify-content: center; padding: 11px; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.role-pick .rp { border: 1px solid var(--border); border-radius: 8px; padding: 10px; font-size: 12.5px; cursor: pointer; text-align: center; }
.role-pick .rp:hover { border-color: var(--accent); }
.role-pick .rp.sel { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .sidebar { position: fixed; left: -232px; z-index: 50; transition: left .2s; }
  .sidebar.open { left: 0; }
  .g2,.g3,.g4,.form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .menu-toggle { display: inline-flex !important; }
  .sidebar-close { display: inline-flex; }
  .sidebar-backdrop.open { display: block; }

  /* 상단바: 좁은 화면에서는 좌우 여백/간격만 줄인다 (라벨은 PC/모바일 공통으로 이미 짧음) */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-btn { padding: 7px 9px; }
}
.menu-toggle { display: none; }

/* 모바일 사이드바 배경 클릭 시 닫기용 오버레이 */
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 40; }

/* 모바일 사이드바 닫기 버튼 (데스크탑에서는 숨김) */
.sidebar-close {
  position: absolute; top: 16px; right: 14px; width: 26px; height: 26px; align-items: center; justify-content: center;
  background: none; border: none; color: #94a3b8; font-size: 15px; cursor: pointer; border-radius: 6px;
}
.sidebar-close:hover { background: var(--sidebar-2); color: #fff; }
