/* ============================================================
   Mirage.cltv v2 — 글로벌 스타일
   네이비 / 슬레이트 그레이 / 화이트 중심
   ============================================================ */

/* ── 변수 ── */
:root {
  --navy-900: #0f172a;
  --navy-800: #1e293b;
  --navy-700: #334155;
  --navy-600: #475569;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50:  #f8fafc;
  --white:     #ffffff;
  --accent:    #3b82f6;
  --accent-h:  #2563eb;
  --success:   #10b981;
  --warn:      #f59e0b;
  --danger:    #ef4444;
  --danger-h:  #dc2626;
}

/* ── 리셋 / 기본 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Pretendard', 'Apple SD Gothic Neo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: var(--navy-900); background: var(--slate-50); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── 레이아웃 — 사이드바 + 메인 ── */
#app { display: flex; min-height: 100vh; }

/* 사이드바 */
#sidebar {
  width: 220px; min-width: 220px;
  background: var(--navy-900);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  overflow-y: auto;
}
#sidebar .logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--navy-700);
}
#sidebar .logo .brand {
  font-size: 13px; font-weight: 700; letter-spacing: 0.08em;
  color: var(--white); text-transform: uppercase;
}
#sidebar .logo .version {
  font-size: 10px; color: #64748b; margin-top: 2px;
}
#sidebar nav { flex: 1; padding: 10px 0; }
#sidebar nav .section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
  color: #475569; text-transform: uppercase;
  padding: 14px 20px 6px;
}
#sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; font-size: 13px; font-weight: 500;
  color: #94a3b8;
  transition: background 0.12s, color 0.12s;
  border-radius: 0;
}
#sidebar nav a:hover { background: var(--navy-800); color: var(--white); }
#sidebar nav a.active {
  background: var(--navy-700); color: var(--white);
  border-left: 3px solid var(--accent);
}
#sidebar nav a i { width: 16px; text-align: center; font-size: 13px; }
#sidebar .sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--navy-700);
}
#sidebar .sidebar-footer .user-info {
  font-size: 12px; color: #94a3b8; margin-bottom: 8px;
}
#sidebar .sidebar-footer .user-info .uname { color: var(--white); font-weight: 600; }
#sidebar .sidebar-footer .user-info .urole {
  display: inline-block; margin-left: 6px;
  font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 99px;
  background: var(--navy-700); color: #94a3b8; text-transform: uppercase;
}
#sidebar .sidebar-footer button {
  font-size: 12px; color: #64748b; background: none; border: none;
  display: flex; align-items: center; gap: 6px;
}
#sidebar .sidebar-footer button:hover { color: #94a3b8; }

/* 메인 콘텐츠 영역 */
#main {
  margin-left: 220px; flex: 1;
  display: flex; flex-direction: column; min-height: 100vh;
}
#topbar {
  height: 52px; min-height: 52px;
  background: var(--white);
  border-bottom: 1px solid var(--slate-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
#topbar .page-title { font-size: 15px; font-weight: 700; color: var(--navy-800); }
#topbar .topbar-actions { display: flex; align-items: center; gap: 10px; }
#content { flex: 1; padding: 24px; }

/* ── KPI 카드 ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--white); border-radius: 12px;
  padding: 20px 22px; border: 1px solid var(--slate-200);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.kpi-card .label { font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.kpi-card .value { font-size: 24px; font-weight: 800; color: var(--navy-900); font-variant-numeric: tabular-nums; line-height: 1; }
.kpi-card .value.accent  { color: var(--accent); }
.kpi-card .value.success { color: var(--success); }
.kpi-card .value.warn    { color: var(--warn); }
.kpi-card .value.danger  { color: var(--danger); }
.kpi-card .sub { font-size: 11px; color: #94a3b8; margin-top: 6px; }
.kpi-card .badge-note { font-size: 10px; padding: 2px 7px; border-radius: 99px; background: var(--slate-100); color: #64748b; margin-top: 6px; display: inline-block; }

/* ── 섹션 그리드 ── */
.section-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.section-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.section-grid.full  { grid-template-columns: 1fr; }

/* ── 카드 ── */
.card {
  background: var(--white); border-radius: 12px;
  border: 1px solid var(--slate-200);
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--slate-100);
}
.card-header .card-title { font-size: 13px; font-weight: 700; color: var(--navy-800); }
.card-header .card-badge { font-size: 11px; color: #64748b; }
.card-body { padding: 0; }

/* ── 테이블 ── */
.tbl-wrap { overflow-x: auto; }
table.v2tbl { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.v2tbl thead tr { background: var(--slate-50); border-bottom: 1px solid var(--slate-200); }
table.v2tbl th {
  padding: 9px 14px; font-size: 11px; font-weight: 600;
  color: #64748b; text-align: left; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .04em;
}
table.v2tbl th.r { text-align: right; }
table.v2tbl td {
  padding: 11px 14px; font-size: 13px; color: var(--navy-800);
  border-bottom: 1px solid var(--slate-100);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
table.v2tbl td.r { text-align: right; font-variant-numeric: tabular-nums; }
table.v2tbl td.amt { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
/* 금액 컬럼 — 숫자+단위 한 줄 고정, 최소 너비 보장 */
table.v2tbl td.amt-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
  min-width: 100px;
}
/* 텍스트 컬럼 — 말줄임 + 툴팁 */
table.v2tbl td.txt-col {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0; /* table-layout:fixed 와 함께 동작 */
}
table.v2tbl tbody tr { cursor: pointer; transition: background .1s; }
table.v2tbl tbody tr:hover { background: var(--slate-50); }
table.v2tbl tbody tr:last-child td { border-bottom: none; }
table.v2tbl .muted { color: #94a3b8; font-style: italic; }

/* ── 상태 배지 ── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px;
  white-space: nowrap;
}
.badge.촬영     { background: #dbeafe; color: #1d4ed8; }
.badge.보정중   { background: #fef3c7; color: #b45309; }
.badge.납품완료 { background: #d1fae5; color: #065f46; }
.badge.보류     { background: #f3f4f6; color: #6b7280; }
.badge.취소     { background: #fee2e2; color: #991b1b; }
.badge.admin    { background: #ede9fe; color: #6d28d9; }
.badge.editor   { background: #dbeafe; color: #1d4ed8; }
.badge.viewer   { background: #f3f4f6; color: #6b7280; }

/* ── 버튼 ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; padding: 8px 16px;
  border-radius: 8px; border: none; transition: background .12s, opacity .12s;
  white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: var(--slate-100); color: var(--navy-700); border: 1px solid var(--slate-200); }
.btn-secondary:hover { background: var(--slate-200); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-ghost { background: transparent; color: #64748b; padding: 6px 10px; }
.btn-ghost:hover { background: var(--slate-100); color: var(--navy-800); }
.btn-sm { font-size: 12px; padding: 5px 11px; }
.btn-icon { padding: 7px; background: transparent; color: #94a3b8; border: none; border-radius: 6px; }
.btn-icon:hover { background: var(--slate-100); color: var(--navy-700); }
.btn-icon.danger:hover { background: #fee2e2; color: var(--danger); }

/* ── 폼 요소 ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: #475569; margin-bottom: 5px; }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--slate-200); border-radius: 8px;
  font-size: 13px; color: var(--navy-900); background: var(--white);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.form-input.readonly { background: var(--slate-50); color: #64748b; cursor: default; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }

/* ── 모달 ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 60px; z-index: 200; overflow-y: auto;
}
.modal {
  background: var(--white); border-radius: 14px;
  width: 100%; max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,.18);
  animation: modalIn .18s ease-out;
}
.modal.wide { max-width: 800px; }
@keyframes modalIn { from { opacity:0; transform:translateY(-14px); } to { opacity:1; transform:translateY(0); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--slate-200);
}
.modal-header h2 { font-size: 15px; font-weight: 700; color: var(--navy-900); }
.modal-body { padding: 22px; }
.modal-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding: 14px 22px; border-top: 1px solid var(--slate-100);
  background: var(--slate-50); border-radius: 0 0 14px 14px;
}

/* ── 페이지네이션 ── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 14px; border-top: 1px solid var(--slate-100); }
.pg-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 500; border-radius: 6px;
  border: 1px solid transparent; background: transparent; color: #64748b;
  cursor: pointer; transition: all .1s;
}
.pg-btn:hover:not(:disabled) { background: var(--slate-100); color: var(--navy-800); }
.pg-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.pg-btn:disabled { opacity: .35; cursor: default; }
.pg-total { font-size: 12px; color: #94a3b8; margin-left: 8px; }

/* ── 필터바 ── */
.filterbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--slate-100);
  background: var(--white); flex-wrap: wrap;
}
.search-wrap {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--slate-200); border-radius: 8px;
  padding: 7px 12px; background: var(--white); flex: 1; min-width: 200px;
}
.search-wrap i { color: #94a3b8; font-size: 13px; }
.search-wrap input { border: none; outline: none; font-size: 13px; color: var(--navy-900); width: 100%; background: transparent; }

/* ── 상세 패널 ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.detail-row {
  display: flex; flex-direction: column;
  padding: 12px 18px; border-bottom: 1px solid var(--slate-100);
}
.detail-row .dl { font-size: 11px; font-weight: 600; color: #94a3b8; text-transform: uppercase; margin-bottom: 3px; }
.detail-row .dv { font-size: 13px; color: var(--navy-900); }
.detail-row .dv.muted { color: #94a3b8; font-style: italic; }
.detail-row .dv.amt { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ── 빈 상태 ── */
.empty-state { padding: 48px 24px; text-align: center; }
.empty-state i { font-size: 32px; color: #cbd5e1; margin-bottom: 12px; }
.empty-state p { font-size: 13px; color: #94a3b8; }

/* ── 알림 토스트 ── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 10px; min-width: 260px; max-width: 360px;
  box-shadow: 0 4px 16px rgba(0,0,0,.14); font-size: 13px; font-weight: 500;
  animation: toastIn .2s ease-out;
}
@keyframes toastIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:translateX(0); } }
.toast.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.toast.error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.toast.info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.toast.warn    { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }

/* ── Audit Log 특수 스타일 ── */
.audit-action {
  display: inline-flex; align-items: center;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: .04em;
}
.audit-action.CREATE       { background: #d1fae5; color: #065f46; }
.audit-action.UPDATE       { background: #dbeafe; color: #1e40af; }
.audit-action.SOFT_DELETE  { background: #fef3c7; color: #92400e; }
.audit-action.RESTORE      { background: #ede9fe; color: #5b21b6; }
.audit-action.HARD_DELETE  { background: #fee2e2; color: #991b1b; }
.audit-action.LOGIN        { background: #f0fdf4; color: #166534; }
.audit-action.LOGOUT       { background: #f9fafb; color: #6b7280; }
.audit-action.LOGIN_FAIL   { background: #fef2f2; color: #b91c1c; }
.audit-action.ROLE_CHANGE  { background: #faf5ff; color: #6d28d9; }
.audit-action.PASSWORD_CHANGE { background: #fff7ed; color: #c2410c; }
.audit-action.EXPORT       { background: #f0f9ff; color: #0369a1; }
.audit-action.SESSION_REVOKE { background: #fef2f2; color: #b91c1c; }

/* ── 차트 래퍼 ── */
.chart-wrap { padding: 16px 18px; }

/* ── 긴급 알림 배지 ── */
.urgent-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 4px;
}
.urgent-badge.d0 { background: #fee2e2; color: #991b1b; }
.urgent-badge.d3 { background: #ffedd5; color: #c2410c; }
.urgent-badge.d7 { background: #fef3c7; color: #b45309; }

/* ── 로그인 화면 ── */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--navy-900);
}
.login-card {
  background: var(--white); border-radius: 16px;
  padding: 40px; width: 100%; max-width: 400px;
  box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.login-card .login-logo { text-align: center; margin-bottom: 28px; }
.login-card .login-logo .brand { font-size: 18px; font-weight: 800; color: var(--navy-900); letter-spacing: .06em; }
.login-card .login-logo .sub   { font-size: 12px; color: #94a3b8; margin-top: 4px; }

/* ── 설정 페이지 ── */
.settings-section { margin-bottom: 28px; }
.settings-section h3 { font-size: 14px; font-weight: 700; color: var(--navy-800); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--slate-200); }

/* ── 확인 다이얼로그 ── */
.confirm-dialog .modal { max-width: 400px; }
.confirm-dialog .icon-wrap { text-align: center; padding: 20px 0 8px; font-size: 36px; }

/* ── 반응형 ── */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .section-grid.three { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
  #sidebar { width: 0; overflow: hidden; }
  #main { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .section-grid, .section-grid.three { grid-template-columns: 1fr; }
  .form-row, .form-row.three { grid-template-columns: 1fr; }
}

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── 기타 유틸 ── */
.text-muted  { color: #94a3b8; }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.text-warn   { color: var(--warn); }
.font-tabular{ font-variant-numeric: tabular-nums; }
.divider { border: none; border-top: 1px solid var(--slate-200); margin: 20px 0; }
.tag { display: inline-flex; align-items: center; font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--slate-100); color: #475569; }
