/* S3 대출서류 열람 — 다크 · 엔터프라이즈 핀테크 · 미니멀
   토큰은 SYSTEM_DESIGN.md §13 에서 추출(rcvbridge 비주얼 언어 계승). */

:root {
  --bg: #0a0a0a;
  --surface-1: #0f0f0f;
  --surface-2: #141414;
  --text-primary: #ffffff;
  --text-bright: #d0d0d0;
  --text-secondary: #a0a0a0;
  --text-muted: #808080;
  --text-faint: #606060;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.2);
  --accent-bg: #ffffff;
  --accent-fg: #0a0a0a;
  --accent-hover: #e8e8e8;
  --marker: #ff5f56;
  --ok: #27c93f;
  --radius: 8px;
  --radius-lg: 12px;
  --container: 1280px;
  --pad-x: 24px;
  --font-sans: system-ui, -apple-system, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.mono {
  font-family: var(--font-mono);
}

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s;
  white-space: nowrap;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn-primary {
  background: var(--accent-bg);
  color: var(--accent-fg);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-bright);
  border-color: var(--border-strong);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-hover);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.spin {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.btn-icon {
  padding: 7px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  display: inline-flex;
}

.btn-icon:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.04);
}

.btn-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}

/* ---------- 로그인 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
}

.login-brand {
  margin-bottom: 28px;
}

.login-brand .logo {
  height: 22px;
  width: auto;
  display: block;
  margin-bottom: 12px;
  opacity: 0.95;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* 상단바 로고 워드마크 */
.topbar-brand .logo {
  height: 18px;
  width: auto;
  display: block;
  opacity: 0.95;
}

.topbar-brand .sep {
  color: var(--border-hover);
  font-weight: 300;
}

.login-panel {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.login-panel h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-panel .hint {
  margin: 0 0 24px;
  font-size: 13px;
  color: var(--text-muted);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 7px;
}

.field input {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.field input::placeholder {
  color: var(--text-faint);
}

.field input:focus {
  outline: none;
  border-color: var(--border-hover);
}

.form-error {
  min-height: 18px;
  margin: -4px 0 14px;
  font-size: 12.5px;
  color: var(--marker);
}

.login-panel .btn-primary {
  width: 100%;
  padding: 12px;
  font-size: 14px;
}

/* ---------- 앱 셸 ---------- */
.app {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--pad-x);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 14px var(--pad-x);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-title {
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  font-size: 15px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
}

.user-chip .uname {
  color: var(--text-bright);
  font-weight: 600;
}

.badge-admin {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent-fg);
  background: var(--accent-bg);
  padding: 2px 7px;
  border-radius: 5px;
}

/* ---------- 브레드크럼 ---------- */
.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 18px 0 10px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.crumb {
  color: var(--text-muted);
  padding: 3px 6px;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
}

.crumb.link {
  cursor: pointer;
}

.crumb.link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.crumb.current {
  color: var(--text-primary);
  font-weight: 600;
}

.crumb-sep {
  color: var(--text-faint);
  user-select: none;
}

/* ---------- 검색/컨트롤 ---------- */
.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0 4px;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 420px;
}

.search svg {
  position: absolute;
  left: 12px;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  pointer-events: none;
}

.search input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.search input::placeholder {
  color: var(--text-faint);
}

.search input:focus {
  outline: none;
  border-color: var(--border-hover);
}

.controls-summary {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ---------- 더 보기 ---------- */
#list-more:not(:empty) {
  display: flex;
  justify-content: center;
  padding: 16px 0 4px;
}

.more-btn {
  min-width: 200px;
}

.more-btn:disabled {
  opacity: 0.6;
}

/* ---------- 툴바 ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  min-height: 30px;
}

.toolbar-info {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ti-note {
  font-size: 12px;
  color: var(--text-muted);
}

.toolbar-info .count {
  color: var(--text-bright);
  font-weight: 600;
  font-family: var(--font-mono);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

/* ---------- 파일 목록 ---------- */
.listing {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface-1);
}

/* 목록 하단 안내(미리보기 제약 등) */
.list-hint {
  margin: 10px 2px 40px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.list-hint svg {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.list-head {
  display: grid;
  grid-template-columns: 34px 1fr 110px 150px;
  gap: 12px;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.list-head .col-size {
  text-align: right;
}

.list-head .col-actions {
  text-align: right;
}

.row {
  display: grid;
  grid-template-columns: 34px 1fr 110px 150px;
  gap: 12px;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  border-left: 2px solid transparent;
  transition: background 0.15s, border-color 0.15s;
  user-select: none; /* shift+클릭 범위선택 시 텍스트 드래그 방지 */
}

.row-file {
  cursor: pointer; /* 행 전체가 선택 토글 타깃 */
}

.row:last-child {
  border-bottom: none;
}

.row:hover {
  background: var(--surface-2);
}

.row.selected {
  border-left-color: var(--accent-bg);
  background: var(--surface-2);
}

.row-folder {
  cursor: pointer;
}

.row-folder:hover {
  border-left-color: var(--border-hover);
}

.cell-check {
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-name {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.name-icon {
  flex-shrink: 0;
  display: inline-flex;
  color: var(--text-muted);
}

.row-folder .name-icon {
  color: var(--text-bright);
}

.name-icon svg {
  width: 18px;
  height: 18px;
  display: block;
}

.name-text {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-folder .name-text {
  color: var(--text-primary);
  font-weight: 500;
}

.cell-size {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
}

.cell-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

.folder-chev {
  color: var(--text-faint);
  display: inline-flex;
}

.folder-chev svg {
  width: 16px;
  height: 16px;
}

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  background: var(--bg);
  cursor: pointer;
  position: relative;
  transition: background 0.15s, border-color 0.15s;
}

input[type="checkbox"]:checked {
  background: var(--accent-bg);
  border-color: var(--accent-bg);
}

input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  /* 박스 정중앙 기준으로 체크마크 배치(고정 px 오프셋은 크기·box-sizing 에 따라 어긋난다).
     체크마크는 꼬리 때문에 시각 중심이 약간 아래라 top 을 살짝 위로 보정한다. */
  left: 50%;
  top: 45%;
  width: 4px;
  height: 8px;
  border: solid var(--accent-fg);
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
}

input[type="checkbox"]:indeterminate {
  background: var(--accent-bg);
  border-color: var(--accent-bg);
}

input[type="checkbox"]:indeterminate::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 6.5px;
  width: 8px;
  height: 2px;
  background: var(--accent-fg);
  border: 0;
  transform: none;
}

input[type="checkbox"]:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ---------- 상태 표시 ---------- */
.state {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
}

.state-icon {
  color: var(--text-faint);
  margin-bottom: 14px;
  display: inline-flex;
}

.state-icon svg {
  width: 34px;
  height: 34px;
}

.state-title {
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
}

.state-sub {
  font-size: 13px;
  color: var(--text-faint);
}

.state-error .state-icon {
  color: var(--marker);
}

.state-action {
  margin-top: 16px;
}

.section-label {
  padding: 12px 16px 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  /* 패널 제목 = 카드의 "메인 타이틀" — 값 못지않게 강조(흰색) */
  color: var(--text-primary);
}

/* ---------- 모달 ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade 0.15s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.modal {
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  max-height: 100%;
  width: 100%;
  overflow: hidden;
}

.modal-preview {
  max-width: 1100px;
  height: 90vh;
}

.modal-script {
  max-width: 720px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-head-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.modal-title {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.modal-body {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.modal-preview .modal-body {
  padding: 0;
  background: #1a1a1a;
}

.modal-preview iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.modal-script .modal-body {
  padding: 18px;
}

.modal-script p.desc {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.script-box {
  width: 100%;
  min-height: 240px;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  padding: 14px;
  white-space: pre;
  overflow: auto;
}

.script-box:focus {
  outline: none;
  border-color: var(--border-hover);
}

/* ---------- 토스트 ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 200;
  background: var(--surface-2);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  padding: 11px 18px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 푸터 ---------- */
.footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
  margin-top: 8px;
}

.footer-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 40px var(--pad-x);
}

.footer-bottom p {
  margin: 0;
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}

/* ---------- 반응형 ---------- */
@media (max-width: 720px) {
  .list-head,
  .row {
    grid-template-columns: 30px 1fr auto;
  }

  .list-head .col-size,
  .cell-size {
    display: none;
  }

  .topbar-title {
    font-size: 14px;
  }

  .user-chip .uname {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .search {
    max-width: none;
  }

  .controls-summary {
    text-align: right;
  }
}

/* ---------- 어드민 ---------- */
.topbar-link {
  text-decoration: none;
}

.admin-nav {
  display: flex;
  gap: 2px;
  margin: 20px 0 0;
}

.admin-nav:empty {
  display: none;
}

.admin-back {
  background: none;
  border: 0;
  padding: 4px 0;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.admin-back:hover {
  color: var(--text-primary);
}

.admin-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text-secondary);
  font: inherit;
  cursor: pointer;
}

.admin-tab:hover {
  color: var(--text-bright);
}

.admin-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-bg);
}

.admin-main {
  min-height: 300px;
  margin-top: 20px;
}

/* nav(← 대시보드)가 있으면 그것이 상단 여백을 대므로 main 여백은 줄인다.
   대시보드는 nav 가 비어(display:none) main 의 20px 가 상단바와의 간격이 된다. */
.admin-nav:not(:empty) + .admin-main {
  margin-top: 12px;
}

/* ---------- 대시보드 탭 ---------- */
.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.dash-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  transition: border-color 0.15s, background 0.15s;
}

.dash-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  /* 카드의 "메인 타이틀"(사용자 수·감사로그 수·스토리지…) — 흰색 최강조 */
  color: var(--text-primary);
  margin-bottom: 10px;
}

.dash-card-value {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-family: var(--font-mono);
  line-height: 1.1;
}

.dash-card-sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.dash-card-hint {
  margin-top: 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-faint);
  transition: color 0.15s;
}

.dash-card-link {
  cursor: pointer;
}

.dash-card-link:hover,
.dash-card-link:focus-visible {
  background: var(--surface-2);
  border-color: var(--border-hover);
}

.dash-card-link:hover .dash-card-hint,
.dash-card-link:focus-visible .dash-card-hint {
  color: var(--text-bright);
}

.dash-card-link:focus-visible {
  outline: 1px solid var(--border-hover);
  outline-offset: 2px;
}

/* 보안 신호 카드 등 — 값이 경고 상태일 때(--marker 강조) */
.dash-card-warn .dash-card-value {
  color: var(--marker);
}

/* sub 아래 항상 표시되는 강조 줄(예: "현재 잠김 N") — 기간과 무관한 현재 상태용 */
.dash-card-alert {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--marker);
}

/* 비용 카드 — "추정" 태그를 카드 우상단에 얹기 위한 기준점 */
.dash-card-cost {
  position: relative;
}

.dash-card-tag {
  position: absolute;
  top: 20px;
  right: 22px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 2px 8px;
}

/* transfer_usd 는 presign 시점 파일 크기 기반 추정 — storage_usd(CloudWatch 실측)보다 흐리게 */
.dash-card-transfer {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.dash-card-note {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint);
}

/* ---------- 대시보드: 일자별 활동 차트 ---------- */
.dash-chart-panel {
  margin-bottom: 14px;
  /* hover 전송량 팁이 가장자리 컬럼에서 잘리지 않도록(부모 .dash-panel 은 overflow:hidden) */
  overflow: visible;
}

/* 막대·숫자 = 총 이벤트 수 / hover = 전송량 안내 */
.dash-chart-legend {
  padding: 0 18px 2px;
  font-size: 11px;
  color: var(--text-muted);
}

/* 헤더: 제목 + 이전/다음 7일 네비 */
.dash-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-right: 14px;
}

.dash-chart-head .section-label {
  flex: 1;
}

.dash-chart-nav {
  display: flex;
  gap: 6px;
}

.dash-chart-navbtn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 11px;
  transition: color 0.15s, border-color 0.15s;
}

.dash-chart-navbtn:hover:not(:disabled) {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.dash-chart-navbtn:disabled {
  opacity: 0.3;
  cursor: default;
}

.dash-chart-body {
  display: flex;
  align-items: stretch;
  gap: 8px;
  /* 세로 길이 1.5배(140→210). 7일만 보여주므로 가로 스크롤 없음. */
  height: 210px;
  padding: 22px 18px 14px;
}

.dash-chart-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* 항상 표시: 총 이벤트 수 — 막대 꼭대기에 딱 붙는다(막대 자식, bottom:100%).
   hover 시엔 감추고 전송량 팁으로 교체한다. */
.dash-chart-val {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 3px;
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-primary);
  transition: opacity 0.12s;
  pointer-events: none;
}

.dash-chart-col:hover .dash-chart-val {
  opacity: 0;
}

/* hover 시 표시: 업로드/다운로드 전송량(총 이벤트 수 자리에 떠오른다) */
.dash-chart-tip {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 2px 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 5;
}

.dash-chart-col:hover .dash-chart-tip {
  opacity: 1;
}

.dash-chart-col:hover .dash-chart-bar {
  background: var(--text-primary);
}

.dash-chart-bar-wrap {
  flex: 1;
  display: flex;
  align-items: flex-end;
}

.dash-chart-bar {
  position: relative; /* 총 이벤트 수(.dash-chart-val)를 막대 꼭대기에 앵커 */
  width: 100%;
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  background: var(--accent-bg);
  transition: background 0.15s;
}

/* 오늘(마지막) 막대만 살짝 강조 */
.dash-chart-col-today .dash-chart-bar {
  background: var(--text-primary);
}

.dash-chart-date {
  margin-top: 6px;
  font-size: 10px;
  color: var(--text-faint);
  text-align: center;
  white-space: nowrap;
}

.dash-chart-col-today .dash-chart-date {
  color: var(--text-bright);
  font-weight: 600;
}

/* ---------- 대시보드: 패널 그리드(액션 분포·최근 활동 / 최근 로그인·상위 계정) ---------- */
.dash-panels {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

/* 최근 로그인 + 상위 계정 — 두 패널의 비중이 비슷해 동일 폭으로 나눈다 */
.dash-panels-even {
  grid-template-columns: 1fr 1fr;
}

.dash-panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.dash-panel .section-label {
  padding: 14px 18px 10px;
}

/* ---------- 대시보드: 액션 분포 ---------- */
.dash-actions-list {
  padding: 2px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dash-actions-row {
  display: grid;
  grid-template-columns: 96px 1fr 34px;
  align-items: center;
  gap: 10px;
}

.dash-actions-name {
  font-size: 12.5px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-actions-bar {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.dash-actions-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent-bg);
}

.dash-actions-num {
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}

/* ---------- 대시보드: 최근 활동 ---------- */
.dash-activity-body:empty {
  display: none;
}

.dash-activity-body .state {
  padding: 32px 18px;
}

.dash-activity-list {
  display: flex;
  flex-direction: column;
}

.dash-activity-row {
  display: grid;
  grid-template-columns: 132px 120px 96px 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}

.dash-activity-ts {
  color: var(--text-faint);
  font-size: 12px;
  white-space: nowrap;
}

/* 액션이 아니라 계정을 강조한다(사람을 먼저 본다) */
.dash-activity-user {
  color: var(--text-primary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 색은 계정과 동일(흰색), 강조(볼드)는 계정에만 */
.dash-activity-action {
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-activity-target {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dash-activity-foot {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
}

.dash-activity-more {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-faint);
  cursor: pointer;
  transition: color 0.15s;
}

.dash-activity-more:hover {
  color: var(--text-bright);
}

/* ---------- 대시보드: 최근 로그인 ---------- */
.dash-logins-body:empty {
  display: none;
}

.dash-logins-body .state {
  padding: 32px 18px;
}

.dash-logins-list {
  display: flex;
  flex-direction: column;
}

.dash-login-row {
  display: grid;
  grid-template-columns: 1fr auto 120px;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
}

.dash-login-row .dash-activity-ts {
  text-align: right;
}

@media (max-width: 860px) {
  .dash-panels,
  .dash-panels-even {
    grid-template-columns: 1fr;
  }

  .dash-activity-row {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: "ts user" "action target";
    row-gap: 4px;
  }

  .dash-activity-ts {
    grid-area: ts;
  }

  .dash-activity-user {
    grid-area: user;
    text-align: right;
  }

  .dash-activity-action {
    grid-area: action;
  }

  .dash-activity-target {
    grid-area: target;
    text-align: right;
  }

  .dash-chart-body {
    height: 165px;
    gap: 6px;
    padding: 22px 12px 12px;
  }

  .dash-chart-date {
    font-size: 9px;
  }
}

.pw-alt {
  margin-top: 16px;
  text-align: center;
}

/* ---------- 페이지 액션(새 폴더 · 업로드) ---------- */
.page-actions {
  display: flex;
  gap: 8px;
  padding: 4px 0 2px;
}

.page-actions:empty {
  display: none;
}

.nf-loc {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-muted);
  word-break: break-all;
}

/* ---------- 계정 탭 ---------- */
.acct-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 18px;
}

.acct-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.acct-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.acct-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.acct-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-bright);
  vertical-align: middle;
}

.acct-table tbody tr:hover td {
  background: var(--surface-1);
}

.acct-mono {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.acct-dim {
  color: var(--text-muted);
}

.acct-role-plain {
  color: var(--text-muted);
}

.acct-empty {
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.acct-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.acct-chip {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-bright);
}

.acct-status {
  display: inline-block;
  font-size: 12px;
  color: var(--text-muted);
}

.acct-status.locked {
  color: var(--marker);
  font-weight: 600;
}

.acct-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.acct-del {
  padding: 5px 12px;
}

/* ---------- 감사로그 탭 ---------- */
.audit-count {
  font-size: 12.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.audit-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 18px;
}

.audit-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.audit-filter label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.audit-select,
.audit-date {
  padding: 8px 11px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.audit-select:focus,
.audit-date:focus {
  outline: none;
  border-color: var(--border-hover);
}

/* 액션이 아니라 계정을 강조한다 — acct-mono(모노 폰트)는 그대로 두고 색·굵기만 덧입힌다 */
.audit-account {
  color: var(--text-bright);
  font-weight: 600;
}

.audit-action {
  color: var(--text-secondary);
}

.audit-num {
  text-align: right;
  white-space: nowrap;
}

.audit-nowrap {
  white-space: nowrap;
}

.audit-target {
  display: inline-block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-bright);
}

.audit-more:not(:empty) {
  display: flex;
  justify-content: center;
  padding: 16px 0 4px;
}

/* ---------- 폼 모달 ---------- */
.modal-form {
  max-width: 520px;
}

.modal-form .modal-body {
  padding: 20px;
}

.field-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field-check label {
  margin-bottom: 0;
  cursor: pointer;
}

.field-check input[type="checkbox"] {
  /* 기본 16px 커스텀 체크박스를 그대로 — 크기를 바꾸면 ::after 체크마크가 어긋난다. */
  flex: none;
  cursor: pointer;
}

.field-req {
  color: var(--marker);
}

/* ---------- 비밀번호 입력(눈알 토글 + 실시간 정책 체크) ---------- */
.pw-wrap {
  position: relative;
  display: block;
}

.pw-wrap input {
  padding-right: 40px;
}

.pw-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px;
  background: none;
  border: 0;
  color: var(--text-muted);
  display: inline-flex;
  border-radius: 6px;
}

.pw-eye:hover {
  color: var(--text-bright);
}

.pw-eye svg {
  width: 16px;
  height: 16px;
  display: block;
}

.pw-checks {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
}

.pw-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-faint);
  transition: color 0.15s;
}

.pw-check-mark {
  display: inline-flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  border: 1px solid var(--border-hover);
  border-radius: 4px;
  color: transparent;
}

.pw-check.met {
  color: var(--ok);
}

.pw-check.met .pw-check-mark {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--accent-fg);
}

.prefix-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prefix-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prefix-row input {
  flex: 1;
  width: auto;
  font-family: var(--font-mono);
}

.prefix-rm {
  flex-shrink: 0;
  padding: 8px 10px;
  font-size: 16px;
  line-height: 1;
}

/* "+ 추가"와 "탐색해서 추가"를 한 줄에 배치하는 액션 행 */
.field-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.field-add {
  margin-top: 0;
}

.field-note {
  margin: -2px 0 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.policy-hint {
  margin: -8px 0 16px;
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.7;
}

.form-warn {
  min-height: 0;
  margin: 0 0 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-bright);
  border-left: 2px solid var(--border-hover);
  padding-left: 10px;
}

.form-warn:empty {
  display: none;
}

/* 되돌릴 수 없는 동작(버저닝 없는 덮어쓰기 등)을 고지하는 변형. .form-warn 과 함께 붙임.
   중립색으로 두면 바로 아래 primary 버튼과 위계가 뒤집혀 경고가 본문처럼 읽힘. */
.form-danger {
  color: var(--marker);
  border-left-color: var(--marker);
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* foot 가 .modal 직속 자식인 모달(업로드·탐색)은 감싸는 body 패딩이 없어
   버튼이 가장자리에 붙는다 — 좌우·아래 패딩을 직접 준다.
   (폼 모달의 foot 은 .modal-body 안에 있어 여기 매칭되지 않는다) */
.modal > .modal-foot {
  padding: 16px 18px;
}

/* ---------- 1회 비밀번호 모달 ---------- */
.np-line {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

.np-user {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

.np-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 7px;
}

.np-pw-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.np-pw {
  flex: 1;
  padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.02em;
}

.np-pw:focus {
  outline: none;
  border-color: var(--border-hover);
}

.np-warn {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--marker);
}

/* ---------- 삭제 모달 ---------- */
.del-confirm {
  margin: 0 0 16px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-bright);
}

.del-user {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* ---------- 업로드 큐 모달 ---------- */
.modal-upload {
  max-width: 640px;
}

.upl-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.upl-agg {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upl-agg-text {
  font-size: 12.5px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.upl-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 46vh;
  overflow-y: auto;
}

.upl-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.upl-row:last-child {
  border-bottom: 0;
}

.upl-row-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.upl-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upl-size {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.upl-status {
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-secondary);
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 412(이미 있음)는 완료 계열 — 실패색으로 보이면 사용자가 재업로드를 반복. */
.upl-row[data-state="done"] .upl-status,
.upl-row[data-state="duplicate"] .upl-status {
  color: var(--ok);
}

.upl-row[data-state="failed"] .upl-status {
  color: var(--marker);
}

.upl-bar {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.upl-bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--accent-bg);
  transition: width 0.15s ease;
}

.upl-row[data-state="done"] .upl-bar-fill,
.upl-row[data-state="duplicate"] .upl-bar-fill {
  background: var(--ok);
}

.upl-row[data-state="failed"] .upl-bar-fill {
  background: var(--marker);
}

.upl-row[data-state="skipped"] .upl-bar-fill {
  background: var(--text-faint);
}

.upl-agg .upl-bar {
  height: 6px;
}

/* ---------- 업로드 전 대조 모달 ---------- */
/* .modal-form 과 함께 붙으므로 특이도를 올려 둠. 같은 특이도면 어느 쪽이 이기는지가
   파일 안의 선언 순서에 달려 규칙을 옮기는 순간 조용히 520px 로 좁아짐. */
.modal.modal-check {
  max-width: 640px;
}

.chk-sec {
  margin-bottom: 18px;
}

.chk-sec:last-child {
  margin-bottom: 0;
}

.chk-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.chk-sec-warn .chk-title {
  color: var(--marker);
}

.chk-note {
  margin: 6px 0 10px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

/* 행 수를 CHECK_LIST_MAX 로 막아도 모달 높이를 넘길 수 있어 여기서 스크롤. */
.chk-list {
  max-height: 26vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.chk-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.chk-row:last-child {
  border-bottom: 0;
}

.chk-name {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chk-meta {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.chk-more {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- prefix 탐색 모달 ---------- */
/* 계정 생성/편집의 "탐색해서 추가" 버튼(허용 prefix 섹션 전용) — .field-actions 행에 인라인 */

.modal-browse {
  max-width: 640px;
  height: 72vh;
}

/* 브레드크럼·선택바는 헤더/푸터처럼 고정, 목록만 스크롤 */
.browse-crumbs {
  padding: 10px 18px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.browse-selected {
  display: none;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.browse-selected.has-sel {
  display: block;
}

.browse-body {
  padding: 6px 8px;
}

.browse-list {
  display: flex;
  flex-direction: column;
}

.browse-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius);
}

.browse-row:hover {
  background: rgba(255, 255, 255, 0.05);
}

.browse-check {
  flex-shrink: 0;
}

.browse-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 13px;
}

.browse-name:hover {
  color: var(--text-primary);
}

.browse-chev {
  flex-shrink: 0;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}

.browse-more {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
}

/* 선택 칩 — .acct-chip 기반, 내부에 × 제거 버튼 */
.browse-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 320px;
}

.browse-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.browse-chip-rm {
  flex-shrink: 0;
  border: 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}

.browse-chip-rm:hover {
  color: var(--text-primary);
}
