/* ============================================================
   사용자테넌트 관리 시스템 - 공통 스타일
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* 브랜드 색상 */
  --brand:         #6366f1;
  --brand-dark:    #4f46e5;
  --brand-darker:  #3730a3;
  --brand-light:   #eef2ff;
  --brand-glow:    rgba(99,102,241,.18);

  /* 역할 색상 */
  --c-admin:       #8b5cf6;
  --c-admin-bg:    #f5f3ff;
  --c-teacher:     #0ea5e9;
  --c-teacher-bg:  #f0f9ff;
  --c-student:     #10b981;
  --c-student-bg:  #ecfdf5;

  /* 기본 색상 */
  --danger:        #ef4444;
  --danger-bg:     #fef2f2;
  --success:       #22c55e;
  --warning:       #f59e0b;

  /* 텍스트 */
  --t1: #0f172a;
  --t2: #475569;
  --t3: #94a3b8;

  /* 배경 / 테두리 */
  --bg:      #f8fafc;
  --surface: #ffffff;
  --border:  #e2e8f0;
  --border2: #cbd5e1;

  /* 그림자 */
  --s1: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --s2: 0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);
  --s3: 0 10px 25px rgba(0,0,0,.08), 0 4px 10px rgba(0,0,0,.05);
  --modal-shadow: 0 25px 60px rgba(0,0,0,.18);

  /* 반경 */
  --r1: 6px;
  --r2: 10px;
  --r3: 16px;
  --r4: 24px;

  /* 헤더 높이 */
  --nav-h: 62px;

  /* 기준 해상도 (1920×1080 전체화면) */
  --layout-w: 1920px;
  --layout-h: 1080px;
  --content-pad-x: 32px;
  --content-pad-y: 20px;
}

html {
  width: 100%;
  height: 100%;
}

body {
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--t1);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  width: 100%;
  height: 100%;
  margin: 0;
}

.hidden { display: none !important; }
a { text-decoration: none; color: inherit; }

/* ============================================================
   로그인 페이지
   ============================================================ */
.login-page {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 40%, #4338ca 100%);
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* 배경 장식 원 */
.login-bg { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.login-bg-circle {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
}
.login-bg-circle.c1 { width: 500px; height: 500px; top: -120px; right: -100px; }
.login-bg-circle.c2 { width: 350px; height: 350px; bottom: -80px; left: -60px; }
.login-bg-circle.c3 { width: 200px; height: 200px; top: 40%; left: 30%; }

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--r4);
  padding: 48px 40px 40px;
  box-shadow: var(--modal-shadow);
  border: 1px solid rgba(255,255,255,.1);
}

.login-header { text-align: center; margin-bottom: 36px; }

.login-logo {
  width: 68px; height: 68px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-darker) 100%);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 8px 24px var(--brand-glow);
}
.login-logo svg { width: 34px; height: 34px; color: #fff; }

.login-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--t1);
  margin-bottom: 6px;
}

.login-desc {
  font-size: 13px;
  color: var(--t3);
  letter-spacing: .05em;
  text-transform: uppercase;
}

.login-form .form-field { margin-bottom: 18px; }
.login-form label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--t2);
  margin-bottom: 7px;
}
.login-form label svg { width: 14px; height: 14px; }

.login-form input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r1);
  font-size: 14px;
  color: var(--t1);
  background: var(--bg);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.login-form input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-glow);
}

.input-wrap { position: relative; }
.input-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none; cursor: pointer;
  color: var(--t3); padding: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: color .2s;
}
.pw-toggle svg { width: 18px; height: 18px; }
.pw-toggle:hover { color: var(--t2); }

.login-error {
  display: flex; align-items: center; gap: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--r1);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-error svg { width: 16px; height: 16px; flex-shrink: 0; }

.login-btn {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-darker) 100%);
  color: #fff;
  border: none;
  border-radius: var(--r1);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s, box-shadow .2s, opacity .2s;
  box-shadow: 0 4px 14px var(--brand-glow);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-top: 4px;
}
.login-btn:hover { box-shadow: 0 6px 20px var(--brand-glow); transform: translateY(-1px); }
.login-btn:active { transform: translateY(0); }
.login-btn:disabled { opacity: .7; cursor: not-allowed; transform: none; }

.dot-spin {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.login-hint {
  margin-top: 24px;
  font-size: 12px;
  color: var(--t3);
  text-align: center;
}
.login-hint code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: 'Consolas', monospace;
  color: var(--t2);
}

/* ============================================================
   앱 레이아웃 (index.html)
   ============================================================ */
.app-page {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- 상단 네비게이션 ---------- */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: linear-gradient(90deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  z-index: 200;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  overflow: visible;
}

.topnav-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 var(--content-pad-x);
}

/* 브랜드 로고 */
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-right: 28px;
  flex-shrink: 0;
}
.nav-brand-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,.2);
}
.nav-brand-icon svg { width: 20px; height: 20px; color: #fff; }
.nav-brand-text {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
}

/* 네비게이션 메뉴 */
.nav-menu {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-menu::-webkit-scrollbar { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--r1);
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,.7);
  transition: color .2s, background .2s;
  white-space: nowrap;
  position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.1);
}
.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,.15);
  font-weight: 700;
}
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: -2px; left: 14px; right: 14px;
  height: 2px;
  background: rgba(255,255,255,.9);
  border-radius: 2px;
}

/* 우측 사용자 영역 */
.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  padding-left: 16px;
  flex-shrink: 0;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--r2);
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(255,255,255,.08);
}

.nav-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a78bfa, #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.nav-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.nav-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}
.nav-user-role {
  font-size: 11px;
  color: rgba(255,255,255,.55);
}

.nav-user-id {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,.92);
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 4px;
}

.nav-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: var(--r1);
  font-size: 13px;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: background .15s, border-color .15s;
  flex-shrink: 0;
}
.nav-logout-btn svg { width: 16px; height: 16px; }
.nav-logout-btn:hover {
  background: rgba(239, 68, 68, .22);
  border-color: rgba(254, 202, 202, .55);
}

/* 햄버거 (모바일) */
.nav-hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}
.nav-hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: rgba(255,255,255,.85);
  border-radius: 2px;
  transition: transform .25s, opacity .25s;
}

/* ---------- 메인 콘텐츠 ---------- */
.app-main {
  margin-top: var(--nav-h);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 페이지 히어로 */
.page-hero {
  background: linear-gradient(90deg, #1e1b4b 0%, #312e81 60%, #4338ca 100%);
  padding: 18px 0 20px;
  flex-shrink: 0;
}
.page-hero-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0 var(--content-pad-x);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: rgba(255,255,255,.55);
  margin-bottom: 10px;
}
.breadcrumb svg { width: 14px; height: 14px; }
.breadcrumb span:last-child { color: rgba(255,255,255,.9); }

.page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-title {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.02em;
}
.btn-ghost-light {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.45);
  color: #fff;
}
.btn-ghost-light:hover {
  background: rgba(255,255,255,.2);
}

/* ---------- 본문 영역 ---------- */
.content-area {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--content-pad-y) var(--content-pad-x);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-section { animation: fadeUp .25s ease; }

.page-section-fill {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 14px;
}

.page-section-fill > [id^="stats-"] { flex-shrink: 0; }
.page-section-fill .stat-cards { margin-bottom: 0; }
.page-section-fill .toolbar-card { flex-shrink: 0; margin-bottom: 0; }
.page-section-fill .loading-state { flex-shrink: 0; }
.page-section-fill .clients-pagination-top { flex-shrink: 0; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 통계 카드 ---------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--s1);
  transition: box-shadow .2s, transform .2s;
}
.stat-card:hover { box-shadow: var(--s2); transform: translateY(-1px); }

.stat-icon {
  width: 44px; height: 44px;
  border-radius: var(--r2);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.all     { background: var(--brand-light);    color: var(--brand); }
.stat-icon.admin   { background: var(--c-admin-bg);     color: var(--c-admin); }
.stat-icon.teacher { background: var(--c-teacher-bg);   color: var(--c-teacher); }
.stat-icon.student { background: var(--c-student-bg);   color: var(--c-student); }

.stat-info { display: flex; flex-direction: column; }
.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--t1);
  line-height: 1;
  margin-bottom: 3px;
}
.stat-label { font-size: 12.5px; color: var(--t3); font-weight: 500; }

/* ---------- 툴바 ---------- */
.toolbar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  box-shadow: var(--s1);
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
}
.search-box > svg {
  position: absolute; left: 12px;
  width: 16px; height: 16px;
  color: var(--t3); pointer-events: none;
}
.search-box input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--r1);
  font-size: 13.5px;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: var(--bg);
}
.search-box input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
  background: var(--surface);
}

.toolbar-card-search-right .search-box {
  flex: 0 0 500px;
  width: 500px;
  max-width: 500px;
  margin-left: auto;
}

.filter-tabs {
  display: flex;
  gap: 4px;
}
.client-filters {
  gap: 8px;
  flex-wrap: wrap;
}
.filter-select {
  min-width: 140px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r1);
  font-size: 13px;
  color: var(--t1);
  background: var(--bg);
  outline: none;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.filter-select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
  background: var(--surface);
}
.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--t2);
  transition: all .15s;
}
.filter-tab:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }
.filter-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px var(--brand-glow);
}

.dot { width: 7px; height: 7px; border-radius: 50%; }
.admin-dot   { background: var(--c-admin); }
.teacher-dot { background: var(--c-teacher); }
.student-dot { background: var(--c-student); }

.result-count {
  font-size: 13px;
  color: var(--t3);
  white-space: nowrap;
  font-weight: 600;
}

/* ---------- 테이블 ---------- */
.loading-state {
  display: flex; flex-direction: column;
  align-items: center; gap: 14px;
  padding: 60px 0;
  color: var(--t3);
  font-size: 14px;
}
.spinner-ring {
  width: 38px; height: 38px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  box-shadow: var(--s1);
  overflow: hidden;
}

.table-card-fill:not(.table-card-clients) {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.table-card-fill .data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.table-card-fill .data-table thead th {
  background: #f8fafc;
}

.table-card-fill > .data-table,
.table-card-fill > table {
  flex-shrink: 0;
}

.table-card-clients.table-card-fill {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.table-card-clients.table-card-fill .data-table {
  width: 100%;
  flex: 1;
  min-height: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  padding: 12px 18px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--t3);
  text-transform: uppercase;
  letter-spacing: .07em;
  text-align: left;
}
.data-table th.th-actions { text-align: right; }
.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
  cursor: pointer;
}
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #f1f5ff; }
.data-table tbody tr.row-selected {
  background: #e0e7ff;
  box-shadow: inset 3px 0 0 var(--brand);
}
.data-table tbody tr.row-selected:hover { background: #d4ddff; }
.data-table td { padding: 14px 18px; font-size: 14px; vertical-align: middle; }

/* ---------- 거래처 관리 테이블 ---------- */
.table-card-clients:not(.table-card-fill) {
  overflow-x: auto;
}

.clients-table {
  table-layout: fixed;
  width: 100%;
  min-width: 0;
}

.clients-table th,
.clients-table td {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.clients-table th.th-actions-left,
.clients-table .td-actions-left {
  text-align: left;
}

.clients-table .td-actions-left .act-btn {
  margin-left: 0;
  margin-right: 6px;
}

.clients-table th.th-check,
.clients-table td.td-check {
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  text-align: center;
  padding: 8px 6px;
  overflow: visible;
}

.clients-table th.th-check input,
.clients-table td.td-check input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--brand);
}

.clients-table tbody tr.clients-row {
  height: 72px;
  max-height: 72px;
}

.clients-table .clients-cell,
.clients-table .td-actions-left {
  height: 72px;
  max-height: 72px;
  padding: 8px 10px;
  line-height: 1.35;
  box-sizing: border-box;
  overflow: hidden;
  vertical-align: middle;
}

.clients-table th.clients-col-name,
.clients-table td.clients-col-name {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clients-table .clients-name {
  display: block;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.clients-table th.clients-col-address,
.clients-table td.clients-col-address {
  width: auto;
  min-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clients-table .clients-address {
  display: block;
  color: var(--t2);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.clients-bulk-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin-bottom: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: #fff;
  box-shadow: var(--s1);
}

.clients-bulk-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--t1);
  cursor: pointer;
  user-select: none;
}

.clients-bulk-check input {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--brand);
}

.clients-bulk-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--t2);
}

.clients-bulk-delete-btn {
  margin-left: auto;
  min-width: 96px;
}

.clients-table th.clients-col-memo,
.clients-table td.clients-col-memo {
  width: 64px;
  min-width: 64px;
  max-width: 64px;
}

.clients-table td.clients-col-memo .clients-cell-text {
  display: block;
  -webkit-line-clamp: unset;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clients-table .clients-cell > * {
  max-width: 100%;
}

.clients-table td.clients-col-name .clients-name {
  max-width: 100%;
}

.clients-table .clients-cell-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clients-table th:nth-child(2),
.clients-table td:nth-child(2) { width: 96px; }
.clients-table th:nth-child(3),
.clients-table td:nth-child(3) { width: 72px; }
.clients-table th:nth-child(5),
.clients-table td:nth-child(5) { width: 240px; }
.clients-table th:nth-child(6),
.clients-table td:nth-child(6) { width: 64px; }
.clients-table th:nth-child(7),
.clients-table td:nth-child(7) { width: 88px; }
.clients-table th:nth-child(8),
.clients-table td:nth-child(8) { width: 68px; }
.clients-table th:nth-child(9),
.clients-table td:nth-child(9) { width: 60px; }
.clients-table th:nth-child(10),
.clients-table td:nth-child(10) { width: 60px; }
.clients-table th:nth-child(11),
.clients-table td:nth-child(11) { width: 56px; }
.clients-table th:nth-child(12),
.clients-table td:nth-child(12) { width: 72px; }
.clients-table th:nth-child(13),
.clients-table td:nth-child(13) { width: 64px; }
.clients-table th:nth-child(14),
.clients-table td:nth-child(14) { width: 64px; }
.clients-table th:nth-child(15),
.clients-table td:nth-child(15) { width: 72px; }
.clients-table th:nth-child(16),
.clients-table td:nth-child(16) { width: 56px; }
.clients-table th:nth-child(17),
.clients-table td:nth-child(17) { width: 56px; }
.clients-table th:nth-child(18),
.clients-table td:nth-child(18) { width: 72px; }
.clients-table th:nth-child(19),
.clients-table td:nth-child(19) { width: 56px; }
.clients-table th:nth-child(20),
.clients-table td:nth-child(20) { width: 88px; }
.clients-table th:nth-child(21),
.clients-table td:nth-child(21) { width: 64px; }

.clients-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px 18px;
  background: #fafbff;
}

.clients-pagination-top {
  border: 1px solid var(--border);
  border-radius: var(--r2);
  box-shadow: var(--s1);
  margin-bottom: 0;
}

.clients-pagination .page-indicator {
  font-size: 14px;
  font-weight: 700;
  color: var(--t1);
  min-width: 72px;
  text-align: center;
}

.clients-pagination .page-range {
  font-size: 13px;
  color: var(--t3);
}

.clients-pagination .page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.user-cell { display: flex; align-items: center; gap: 12px; }
.user-ava {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  color: #fff; flex-shrink: 0;
}
.ava-admin   { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.ava-teacher { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.ava-student { background: linear-gradient(135deg, #34d399, #059669); }

.user-name-text { font-weight: 600; color: var(--t1); }
.user-id-text { font-size: 11.5px; color: var(--t3); }

.email-text { color: var(--t2); }

.role-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.chip-admin   { background: var(--c-admin-bg);   color: var(--c-admin); }
.chip-teacher { background: var(--c-teacher-bg); color: var(--c-teacher); }
.chip-student { background: var(--c-student-bg); color: var(--c-student); }

.td-actions { text-align: right; }
.act-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--r1);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--t2);
  margin-left: 6px;
  transition: all .15s;
}
.act-btn svg { width: 14px; height: 14px; }
.act-btn.edit:hover  { border-color: var(--brand);  color: var(--brand);  background: var(--brand-light); }
.act-btn.del:hover   { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }

.empty-state {
  padding: 56px; text-align: center;
  color: var(--t3); font-size: 14px;
}
.empty-state svg { width: 44px; height: 44px; margin-bottom: 12px; stroke: var(--t3); }

/* ---------- 준비 중 페이지 ---------- */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  padding: 80px 24px;
  text-align: center;
}
.coming-soon-icon { font-size: 56px; margin-bottom: 20px; }
.coming-soon h2 { font-size: 22px; font-weight: 700; color: var(--t1); margin-bottom: 10px; }
.coming-soon p { font-size: 14px; color: var(--t2); }
.coming-hint { margin-top: 6px; color: var(--t3) !important; font-size: 13px !important; }

/* ============================================================
   공통 버튼
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r1);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none !important; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 2px 8px var(--brand-glow);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }

.btn-ghost {
  background: transparent;
  color: var(--t2);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--bg); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }

/* ============================================================
   모달
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--surface);
  border-radius: var(--r3);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--modal-shadow);
  animation: slideUp .2s ease;
}
.modal-box.modal-schedule,
.modal-box.modal-clients {
  max-width: min(1600px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.modal-box.modal-clients {
  max-width: min(1280px, 96vw);
}
.modal-box.modal-schedule .modal-body,
.modal-box.modal-clients .modal-body {
  flex: 1;
  overflow: auto;
  padding: 20px 24px 12px;
}
.modal-box.modal-schedule .modal-foot,
.modal-box.modal-clients .modal-foot {
  position: sticky;
  bottom: 0;
  background: var(--surface);
}
.modal-sm { max-width: 480px; }
.modal-map { max-width: min(1400px, 96vw); }
.client-map-body { display: flex; flex-direction: column; gap: 14px; }
.client-map-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r1);
  background: #f8fafc;
}
.client-map-summary-main { min-width: 0; flex: 1; }
.client-map-name {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--t1);
}
.client-map-address,
.client-map-coord {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}
.client-map-link {
  flex-shrink: 0;
  white-space: nowrap;
}
.client-map-wrap {
  position: relative;
  margin-top: 0;
  border: 1px solid var(--border);
  border-radius: var(--r1);
  overflow: hidden;
  background: #eef2f7;
  min-height: min(720px, calc(100vh - 280px));
}
.client-map-image {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
}
.client-map-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-size: 14px;
  color: var(--t2);
  text-align: center;
}
.client-map-error {
  color: var(--danger);
  background: rgba(255, 255, 255, .92);
}

.geocode-workspace { display: flex; flex-direction: column; gap: 14px; }
.geocode-guide {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r1);
  background: #f8fafc;
  font-size: 13px;
  line-height: 1.6;
  color: var(--t2);
}
.geocode-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.geocode-toolbar-left,
.geocode-toolbar-right {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.geocode-input,
.geocode-select,
.geocode-query-input,
.geocode-candidate-select {
  border: 1.5px solid var(--border);
  border-radius: var(--r1);
  padding: 9px 12px;
  font-size: 13px;
  background: #fff;
  color: var(--t1);
}
.geocode-input { min-width: 140px; }
.geocode-search { min-width: 220px; }
.geocode-query-input,
.geocode-candidate-select { width: 100%; min-width: 180px; }
.geocode-summary { display: flex; flex-wrap: wrap; gap: 8px; }
.geocode-table-card { overflow: hidden; }
.geocode-table-wrap {
  overflow: auto;
  max-height: min(720px, calc(100vh - 320px));
}
.geocode-table { min-width: 1180px; }
.geocode-table th,
.geocode-table td { vertical-align: top; font-size: 13px; }
.geocode-address,
.geocode-sub { display: block; max-width: 220px; word-break: break-word; }
.geocode-actions { white-space: nowrap; }
.geocode-actions .act-btn { margin-bottom: 4px; }
.geocode-row.active { background: #eef6ff; }
.geocode-empty { text-align: center; padding: 28px !important; }
.geocode-preview {
  border: 1px solid var(--border);
  border-radius: var(--r1);
  padding: 16px;
  background: #fff;
}
.geocode-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.geocode-preview-head h4 { margin: 0; font-size: 16px; }
.geocode-preview-image {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r1);
  background: #f8fafc;
}

@keyframes slideUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-x {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  border-radius: var(--r1); color: var(--t3);
  transition: background .15s, color .15s;
}
.modal-x svg { width: 18px; height: 18px; }
.modal-x:hover { background: var(--bg); color: var(--t1); }

.modal-body { padding: 20px 24px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px 20px;
  border-top: 1px solid var(--border);
}

/* 폼 필드 */
.field-group { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.field-row > .field-group { margin-bottom: 0; }
.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--t1);
  margin-bottom: 7px;
}
.req { color: var(--danger); }
.opt-hint { font-size: 12px; color: var(--t3); font-weight: 400; }

.field-group input,
.field-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r1);
  font-size: 14px;
  color: var(--t1);
  background: var(--bg);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.field-group input:focus,
.field-group select:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
.field-group input::placeholder { color: var(--t3); }

/* 역할 선택 */
.role-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.role-opt { cursor: pointer; }
.role-opt input { display: none; }
.role-opt-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--r1);
  font-size: 13px;
  font-weight: 600;
  color: var(--t2);
  transition: all .15s;
  background: var(--bg);
}
.role-opt-box svg { width: 20px; height: 20px; }
.role-opt:hover .role-opt-box { border-color: var(--brand-dark); color: var(--brand); background: var(--brand-light); }
.role-opt input:checked ~ .role-opt-box.admin-opt   { border-color: var(--c-admin);   color: var(--c-admin);   background: var(--c-admin-bg); }
.role-opt input:checked ~ .role-opt-box.teacher-opt { border-color: var(--c-teacher); color: var(--c-teacher); background: var(--c-teacher-bg); }
.role-opt input:checked ~ .role-opt-box.student-opt { border-color: var(--c-student); color: var(--c-student); background: var(--c-student-bg); }

.form-error {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--r1);
  padding: 10px 14px;
  font-size: 13px;
  margin-top: 4px;
}
.excel-guide {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--r1);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.excel-guide-title {
  font-size: 13px;
  color: var(--t1);
  font-weight: 700;
  margin-bottom: 6px;
}
.excel-guide ul {
  margin: 0;
  padding-left: 18px;
  color: var(--t2);
  font-size: 12px;
  line-height: 1.5;
}

/* 시간표 그리드 */
.schedule-editor {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.schedule-edit-mode {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.mode-chip {
  border: 1px solid var(--border2);
  border-radius: 18px;
  background: #fff;
  color: var(--t2);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  cursor: pointer;
}
.mode-chip.active {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand-dark);
}
.schedule-editor-top {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 16px;
}
.schedule-editor-top-single {
  grid-template-columns: 1fr 1fr;
}
.schedule-batch-help {
  margin: 4px 0 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r1);
  background: #f8fafc;
  color: var(--t2);
  font-size: 13px;
}
.schedule-grid-pair {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.schedule-grade-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.grade-chip {
  border: 1px solid var(--border2);
  border-radius: 18px;
  background: #fff;
  color: var(--t2);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
}
.grade-chip.active {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand-dark);
}
.schedule-class-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  padding: 2px;
}
.schedule-class-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r1);
  padding: 8px 10px;
  background: #fff;
  font-size: 13px;
  color: var(--t2);
}
.schedule-class-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
}
.schedule-class-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.schedule-grid-wrap {
  border: 1px solid var(--border);
  border-radius: var(--r1);
  overflow: auto;
  max-height: min(680px, calc(100vh - 280px));
}
.schedule-grid {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
  background: #fff;
}
.schedule-grid th,
.schedule-grid td {
  border: 1px solid var(--border);
  text-align: center;
  padding: 8px;
  vertical-align: middle;
}
.schedule-grid thead th {
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  color: var(--t2);
}
.schedule-grid tbody th {
  font-size: 12px;
  font-weight: 700;
  color: var(--t1);
  background: #f8fafc;
  white-space: nowrap;
  min-width: 110px;
}
.schedule-grid tbody th span {
  font-size: 11px;
  font-weight: 500;
  color: var(--t3);
}
.schedule-grid-cell {
  width: 100%;
  border: 1px solid var(--border2);
  background: var(--bg);
  border-radius: var(--r1);
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--t2);
  cursor: pointer;
  transition: all .15s;
  position: relative;
}
.schedule-grid-cell.interactive { cursor: pointer; }
.schedule-grid-cell.has-order {
  padding-right: 24px;
}
.schedule-grid-cell.has-order::after {
  content: attr(data-order);
  position: absolute;
  top: 4px;
  right: 6px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .14);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.schedule-grid-cell:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}
.schedule-grid-cell.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 8px var(--brand-glow);
}

/* 삭제 모달 */
.delete-body { text-align: center; }
.delete-icon-wrap {
  width: 60px; height: 60px;
  background: var(--danger-bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.delete-icon-wrap svg { width: 28px; height: 28px; stroke: var(--danger); }
.delete-body p { font-size: 15px; color: var(--t1); margin-bottom: 6px; }
.delete-warn { font-size: 13px !important; color: var(--t3) !important; }

/* ============================================================
   토스트
   ============================================================ */
.toast-stack {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 1000;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 13px 18px;
  font-size: 13.5px;
  font-weight: 500;
  min-width: 240px; max-width: 360px;
  box-shadow: var(--s3);
  animation: toastIn .25s ease;
}
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger);  }
.toast.warning { border-left: 4px solid var(--warning); }
.toast-icon { font-size: 17px; }
.toast-text { flex: 1; color: var(--t1); }

/* ============================================================
   추가 공통 컴포넌트
   ============================================================ */

/* 텍스트 */
.text-muted { color: var(--t3); font-size: 13px; }
.email-text { color: var(--t2); }

/* 학생 수 카운트 */
.count-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  background: var(--brand-light); color: var(--brand);
}

/* 요일 뱃지 */
.day-badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
  background: #fef3c7; color: #92400e;
}

/* 성적 점수 뱃지 */
.score-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 700;
}
.score-a { background: #dcfce7; color: #15803d; }
.score-b { background: #dbeafe; color: #1d4ed8; }
.score-c { background: #e0f2fe; color: #0369a1; }
.score-d { background: #fef9c3; color: #854d0e; }
.score-f { background: #fee2e2; color: #b91c1c; }

/* ============================================================
   반응형
   ============================================================ */
@media (max-width: 1024px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .nav-menu {
    display: none;
    position: fixed;
    top: var(--nav-h); left: 0; right: 0;
    background: #1e1b4b;
    flex-direction: column;
    align-items: stretch;
    padding: 12px;
    gap: 4px;
    box-shadow: 0 8px 20px rgba(0,0,0,.3);
    max-height: calc(100vh - var(--nav-h));
    overflow-y: auto;
  }
  .nav-menu.open { display: flex; }
  .nav-item { padding: 12px 16px; }
  .nav-item.active::after { display: none; }
  .nav-hamburger { display: flex; }
  .nav-user-info { display: none; }
  .nav-user-id { max-width: 140px; font-size: 12px; }
  .nav-logout-btn { padding: 8px 10px; font-size: 12px; }
  .page-hero-inner { padding: 0 16px; }
  .content-area { padding: 16px; }
  .page-actions { width: 100%; justify-content: flex-end; }
  .toolbar-card { flex-direction: column; align-items: stretch; }
  .toolbar-card-search-right .search-box {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    margin-left: 0;
  }
  .filter-tabs { justify-content: flex-start; flex-wrap: wrap; }
  .field-row { grid-template-columns: 1fr; }
  .schedule-editor-top { grid-template-columns: 1fr; }
  .schedule-class-list { grid-template-columns: 1fr 1fr; }
  .schedule-grid { min-width: 700px; }
  .role-selector { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}

@media (max-width: 480px) {
  .login-card { padding: 32px 24px; }
  .page-title { font-size: 20px; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
}
