/*
 * KoreaID Groupware 공통 스타일. 목업(docs/mockups)과 Blazor 앱이 같은 파일을 쓴다.
 * 로드 순서: bootstrap.min.css -> bootstrap-icons.min.css -> pretendardvariable.css -> tokens.css -> gw.css
 * 기준 문서: docs/DESIGN.md. 새 모양이 필요하면 문서의 Components 표를 먼저 고친다.
 *
 * 반응형 기준은 뷰포트가 아니라 앱 컨테이너(.gw-app)의 폭이다(@container gw). 값은 뷰포트와 같게
 * 동작하지만, 목업이 한 페이지 안에서 PC·375px 틀을 나란히 보여 줄 수 있다.
 * .gw-app은 높이가 뷰포트(100dvh)로 고정되고 .gw-content만 스크롤된다. 덕분에 컨테이너 안의
 * absolute 배치(더보기 시트)가 뷰포트 기준과 같아진다.
 */

/* ---------- Bootstrap 5.3 변수 덮어쓰기 (Sass 없이) ---------- */
:root,
[data-bs-theme=light],
[data-bs-theme=dark] {
  --bs-body-font-family: var(--gw-font-family);
  --bs-body-font-size: var(--gw-text-body-md);
  --bs-body-line-height: 1.5;
  --bs-body-color: var(--gw-on-surface);
  --bs-body-color-rgb: var(--gw-on-surface-rgb);
  --bs-body-bg: var(--gw-neutral);
  --bs-body-bg-rgb: var(--gw-neutral-rgb);
  --bs-secondary-color: var(--gw-on-surface-muted);
  --bs-border-color: var(--gw-border);
  --bs-border-radius: var(--gw-rounded-md);
  --bs-border-radius-lg: var(--gw-rounded-lg);
  --bs-primary: var(--gw-primary);
  --bs-primary-rgb: var(--gw-primary-rgb);
  --bs-link-color: var(--gw-primary);
  --bs-link-color-rgb: var(--gw-primary-rgb);
  --bs-link-hover-color: var(--gw-primary-hover);
  --bs-link-hover-color-rgb: var(--gw-primary-hover-rgb);
  --bs-focus-ring-color: rgba(var(--gw-primary-rgb), .25);
  --bs-form-invalid-color: var(--gw-error);
  --bs-form-invalid-border-color: var(--gw-error);
}

body {
  font-feature-settings: "tnum" 1;
  /* 한글은 어절 단위로 줄바꿈한다(음절 중간에서 끊기지 않게). */
  word-break: keep-all;
  overflow-wrap: break-word;
}

:focus-visible {
  outline: 2px solid var(--gw-primary);
  outline-offset: 2px;
}

/* ---------- 버튼 (button-primary / button-secondary) ---------- */
.btn {
  --bs-btn-font-family: inherit;
  --bs-btn-font-size: var(--gw-text-label-md);
  --bs-btn-font-weight: 600;
  --bs-btn-line-height: 1.4;
  --bs-btn-padding-x: 16px;
  --bs-btn-padding-y: 0;
  --bs-btn-border-radius: var(--gw-rounded-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--gw-row-height);
}

.btn-lg {
  --bs-btn-font-size: var(--gw-text-body-md);
  --bs-btn-padding-x: 20px;
  --bs-btn-border-radius: var(--gw-rounded-md);
  min-height: var(--gw-touch-target);
}

.btn-primary {
  --bs-btn-color: var(--gw-surface);
  --bs-btn-bg: var(--gw-primary);
  --bs-btn-border-color: var(--gw-primary);
  --bs-btn-hover-color: var(--gw-surface);
  --bs-btn-hover-bg: var(--gw-primary-hover);
  --bs-btn-hover-border-color: var(--gw-primary-hover);
  --bs-btn-focus-shadow-rgb: var(--gw-primary-rgb);
  --bs-btn-active-color: var(--gw-surface);
  --bs-btn-active-bg: var(--gw-primary-hover);
  --bs-btn-active-border-color: var(--gw-primary-hover);
  --bs-btn-disabled-color: var(--gw-surface);
  --bs-btn-disabled-bg: var(--gw-primary);
  --bs-btn-disabled-border-color: var(--gw-primary);
}

.btn-outline-secondary {
  --bs-btn-color: var(--gw-secondary);
  --bs-btn-bg: var(--gw-surface);
  --bs-btn-border-color: var(--gw-border-strong);
  --bs-btn-hover-color: var(--gw-on-surface);
  --bs-btn-hover-bg: var(--gw-surface-muted);
  --bs-btn-hover-border-color: var(--gw-secondary);
  --bs-btn-focus-shadow-rgb: var(--gw-primary-rgb);
  --bs-btn-active-color: var(--gw-on-surface);
  --bs-btn-active-bg: var(--gw-surface-muted);
  --bs-btn-active-border-color: var(--gw-secondary);
  --bs-btn-disabled-color: var(--gw-secondary);
  --bs-btn-disabled-bg: var(--gw-surface);
  --bs-btn-disabled-border-color: var(--gw-border-strong);
}

/* ---------- 입력 (input / input-touch) ---------- */
.form-label {
  margin-bottom: 6px;
  font-size: var(--gw-text-label-md);
  font-weight: 600;
}

.form-control {
  min-height: var(--gw-row-height);
  padding: 0 12px;
  background-color: var(--gw-surface);
  border-color: var(--gw-border-strong);
  border-radius: var(--gw-rounded-md);
  font-size: var(--gw-text-body-md);
}

.form-control:focus {
  border-color: var(--gw-primary);
  box-shadow: 0 0 0 3px rgba(var(--gw-primary-rgb), .25);
}

/* 모바일 폼(로그인·비밀번호 변경): 44px. 16px 글자는 iOS가 포커스 때 화면을 확대하지 않는 최소 크기. */
.form-control-lg {
  min-height: var(--gw-touch-target);
  padding: 0 14px;
  border-radius: var(--gw-rounded-md);
  font-size: 16px;
}

.invalid-feedback {
  margin-top: 6px;
  font-size: var(--gw-text-body-sm);
}

/* ---------- 카드 · 알림 · 배지 ---------- */
.gw-card {
  background: var(--gw-surface);
  border: 1px solid var(--gw-border);
  border-radius: var(--gw-rounded-lg);
  padding: var(--gw-space-lg);
  color: var(--gw-on-surface);
}

.alert {
  --bs-alert-padding-x: 16px;
  --bs-alert-padding-y: 12px;
  --bs-alert-margin-bottom: 16px;
  --bs-alert-border-radius: var(--gw-rounded-md);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: var(--gw-text-body-md);
}

.alert > .bi {
  flex: none;
  line-height: 1.5;
}

.gw-alert-error {
  --bs-alert-color: var(--gw-error);
  --bs-alert-bg: var(--gw-error-subtle);
  --bs-alert-border-color: var(--gw-error-subtle);
}

.gw-alert-info {
  --bs-alert-color: var(--gw-primary);
  --bs-alert-bg: var(--gw-primary-subtle);
  --bs-alert-border-color: var(--gw-primary-subtle);
}

.gw-badge-success,
.gw-badge-warning,
.gw-badge-error,
.gw-badge-neutral,
.gw-badge-info {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--gw-rounded-full);
  font-size: var(--gw-text-caption);
  font-weight: 500;
  line-height: 1.4;
}

.gw-badge-success { background: var(--gw-success-subtle); color: var(--gw-success); }
.gw-badge-warning { background: var(--gw-warning-subtle); color: var(--gw-warning); }
.gw-badge-error   { background: var(--gw-error-subtle);   color: var(--gw-error); }
.gw-badge-neutral { background: var(--gw-border);         color: var(--gw-secondary); }
.gw-badge-info    { background: var(--gw-primary-subtle); color: var(--gw-primary); }

.gw-muted {
  color: var(--gw-on-surface-muted);
}

/* ---------- 브랜드 로고 (회사 로고 이미지, 원본 그대로) ---------- */
/* 작은 마크: 모바일·잠금 헤더. KID_mark.png는 KID_logo.png의 투명 여백만 잘라낸 것이다. */
.gw-logo-mark {
  flex: none;
  width: auto;
  height: 24px;
}

/* 전체 로고(심볼 + 한국아이디정보(주) + 영문): 로그인·사이드바. 사이드바(.gw-logo-sidebar, 높이 40px)에서도 같은 이미지를 쓴다. 늘리거나 색을 바꾸지 않는다. */
.gw-logo-full {
  display: block;
  width: min(280px, 100%);
  height: auto;
}

/* ---------- 로그인 ---------- */
.gw-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--gw-space-xl) var(--gw-space-md);
  background: var(--gw-neutral);
}

.gw-login-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--gw-space-lg);
  text-align: center;
}

.gw-login-title {
  margin: 0;
  font-size: var(--gw-text-headline-md);
  font-weight: 700;
  line-height: 1.3;
}

.gw-login-card {
  width: 100%;
  max-width: 400px;
  padding: var(--gw-space-xl) var(--gw-space-lg);
}

.gw-login-foot {
  max-width: 400px;
  margin: var(--gw-space-lg) 0 0;
  font-size: var(--gw-text-body-sm);
  color: var(--gw-on-surface-muted);
  text-align: center;
}

/* ---------- 앱 셸 (D-29) ---------- */
.gw-app {
  container: gw / inline-size;
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  background: var(--gw-neutral);
  color: var(--gw-on-surface);
}

.gw-banner-rehearsal {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  padding: 4px 16px;
  background: var(--gw-warning-subtle);
  border-bottom: 1px solid color-mix(in srgb, var(--gw-warning) 25%, transparent);
  color: var(--gw-warning);
  font-size: var(--gw-text-label-md);
  font-weight: 600;
  text-align: center;
}

.gw-shell {
  display: flex;
  flex: 1;
  min-height: 0;
}

.gw-sidebar {
  display: flex;
  flex: none;
  flex-direction: column;
  width: var(--gw-sidebar-width);
  overflow-y: auto;
  background: var(--gw-surface);
  border-right: 1px solid var(--gw-border);
  color: var(--gw-secondary);
}

/* 사이드바 브랜드 칸: 기존 그룹웨어처럼 전체 로고를 가운데에 둔다. 로고 40px + 위아래 12px. */
.gw-brand {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  height: 64px;
  padding: 0 var(--gw-space-md);
  border-bottom: 1px solid var(--gw-border);
}

.gw-logo-sidebar {
  width: auto;
  height: 40px;
  max-width: 100%;
}

.gw-sidebar nav {
  padding: 12px 8px 16px;
}

.gw-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gw-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--gw-row-height);
  padding: 0 12px;
  border: 0;
  border-radius: var(--gw-rounded-md);
  background: transparent;
  color: var(--gw-secondary);
  font-size: var(--gw-text-body-md);
  text-align: left;
  text-decoration: none;
}

.gw-nav-link .bi {
  flex: none;
  font-size: 16px;
}

.gw-nav-link:hover {
  background: var(--gw-surface-muted);
  color: var(--gw-on-surface);
}

.gw-nav-link.is-active {
  background: var(--gw-primary-subtle);
  color: var(--gw-primary);
  font-weight: 600;
}

.gw-nav-folder .gw-chevron {
  margin-left: auto;
  font-size: 12px;
}

.gw-nav-folder[aria-expanded=false] .gw-chevron {
  transform: rotate(-90deg);
}

.gw-nav-sub {
  margin: 2px 0 4px 18px;
  padding-left: 8px;
  border-left: 1px solid var(--gw-border);
}

.gw-nav-folder[aria-expanded=false] + .gw-nav-sub {
  display: none;
}

.gw-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.gw-header {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  height: var(--gw-header-height);
  padding: 0 var(--gw-space-lg);
  background: var(--gw-surface);
  border-bottom: 1px solid var(--gw-border);
}

.gw-header-brand {
  display: none;
}

/* 첫 로그인 강제 변경 상태: 사이드바·하단 탭 바를 렌더하지 않고, 헤더에 브랜드와 로그아웃만 둔다. */
.gw-app-locked .gw-header-brand {
  display: block;
}

.gw-header-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: var(--gw-text-headline-sm);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gw-header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--gw-on-surface);
}

.gw-content {
  flex: 1;
  min-height: 0;
  padding: var(--gw-space-lg);
  overflow-y: auto;
}

.gw-page-title {
  margin: 0 0 4px;
  font-size: var(--gw-text-headline-md);
  font-weight: 700;
  line-height: 1.3;
}

.gw-tabbar {
  display: none;
  flex: none;
  height: calc(var(--gw-tabbar-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--gw-surface);
  border-top: 1px solid var(--gw-border);
}

.gw-tab {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: var(--gw-touch-target);
  min-height: var(--gw-touch-target);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--gw-on-surface-muted);
  font-size: var(--gw-text-caption);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
}

.gw-tab .bi {
  font-size: 20px;
  line-height: 1;
}

.gw-tab.is-active {
  color: var(--gw-primary);
  font-weight: 600;
}

.gw-tab.is-disabled,
.gw-tab:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* 더보기 시트: 하단 탭 바 위에 올라와 전체 메뉴 트리를 보여 준다. 열림 상태는 .is-open (Blazor 상태). */
.gw-more-sheet {
  position: absolute;
  inset: 0 0 calc(var(--gw-tabbar-height) + env(safe-area-inset-bottom, 0px)) 0;
  z-index: 20;
  display: none;
}

.gw-more-sheet.is-open {
  display: block;
}

.gw-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(var(--gw-on-surface-rgb), .45);
}

.gw-sheet-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  max-height: 85%;
  background: var(--gw-surface);
  border-radius: var(--gw-rounded-lg) var(--gw-rounded-lg) 0 0;
  box-shadow: 0 -8px 24px rgba(var(--gw-on-surface-rgb), .18);
  color: var(--gw-on-surface);
}

.gw-sheet-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 4px 16px;
}

.gw-sheet-title {
  margin: 0;
  font-size: var(--gw-text-headline-sm);
  font-weight: 700;
}

.gw-sheet-body {
  padding: 0 8px 16px;
  overflow-y: auto;
}

.gw-sheet-body .gw-nav-link,
.gw-icon-btn {
  min-height: var(--gw-touch-target);
}

.gw-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--gw-touch-target);
  padding: 0;
  border: 0;
  border-radius: var(--gw-rounded-md);
  background: transparent;
  color: var(--gw-secondary);
}

.gw-icon-btn:hover {
  background: var(--gw-surface-muted);
  color: var(--gw-on-surface);
}

/* 폭에 따라 짝으로 바꿔 보이는 요소: .gw-compact-hide는 768px 미만에서, .gw-wide-hide는 768px 이상에서 숨긴다(헤더 로그아웃). */
.gw-wide-hide {
  display: none;
}

@media (prefers-reduced-motion: no-preference) {
  .gw-more-sheet.is-open .gw-sheet-panel {
    animation: gw-sheet-up .2s ease-out;
  }

  .gw-nav-folder .gw-chevron {
    transition: transform .15s;
  }
}

@keyframes gw-sheet-up {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: none; }
}

/* 768px 미만: 사이드바 대신 하단 탭 바 (D-29) */
@container gw (max-width: 767.98px) {
  .gw-sidebar {
    display: none;
  }

  .gw-tabbar {
    display: flex;
  }

  .gw-header {
    padding: 0 8px 0 var(--gw-space-md);
  }

  .gw-header-brand {
    display: block;
  }

  .gw-header-user,
  .gw-compact-hide {
    display: none;
  }

  .gw-wide-hide {
    display: inline-flex;
  }

  .gw-content {
    padding: var(--gw-space-md);
  }
}

@container gw (min-width: 768px) {
  .gw-more-sheet {
    display: none;
  }
}

/* ---------- 공통 목록 패턴 (D-34): PC는 표, 768px 미만은 카드 ---------- */
.gw-list-wrap {
  overflow-x: auto;
  background: var(--gw-surface);
  border: 1px solid var(--gw-border);
  border-radius: var(--gw-rounded-md);
}

.gw-list {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  color: var(--gw-on-surface);
  font-size: var(--gw-text-body-md);
}

.gw-list th {
  height: var(--gw-row-height);
  padding: 0 12px;
  background: var(--gw-surface-muted);
  border-bottom: 1px solid var(--gw-border);
  color: var(--gw-on-surface-muted);
  font-size: var(--gw-text-label-md);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.gw-list td {
  height: var(--gw-row-height);
  padding: 0 12px;
  border-bottom: 1px solid var(--gw-border);
}

.gw-list tbody tr:last-child td {
  border-bottom: 0;
}

.gw-list tbody tr:hover td {
  background: var(--gw-surface-muted);
}

@container gw (max-width: 767.98px) {
  .gw-list-wrap {
    overflow: visible;
    background: transparent;
    border: 0;
  }

  .gw-list,
  .gw-list tbody,
  .gw-list tr,
  .gw-list td {
    display: block;
  }

  /* 머리글은 시각적으로만 숨기고 접근성 트리에는 남긴다 */
  .gw-list thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .gw-list tbody {
    display: flex;
    flex-direction: column;
    gap: var(--gw-space-sm);
  }

  .gw-list tr {
    padding: 12px 16px;
    background: var(--gw-surface);
    border: 1px solid var(--gw-border);
    border-radius: var(--gw-rounded-md);
  }

  .gw-list td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    height: auto;
    min-height: var(--gw-touch-target);
    padding: 4px 0;
    border-bottom: 0;
    text-align: right;
  }

  .gw-list td::before {
    content: attr(data-label);
    flex: none;
    color: var(--gw-on-surface-muted);
    font-size: var(--gw-text-label-md);
    font-weight: 600;
    text-align: left;
  }

  .gw-list tbody tr:hover td {
    background: transparent;
  }
}

/* ---------- 오류 화면 ---------- */
/* 셸 밖(레이아웃을 못 그리는 500 등)에서 쓰는 전체 화면 바탕 */
.gw-error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: var(--gw-neutral);
}

.gw-error {
  max-width: 440px;
  margin: 0 auto;
  padding: 48px 16px;
  text-align: center;
}

.gw-error-code {
  margin-bottom: 12px;
  color: var(--gw-secondary);
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
}

.gw-error-title {
  margin: 0 0 8px;
  font-size: var(--gw-text-headline-md);
  font-weight: 700;
  line-height: 1.3;
}

.gw-error-text {
  margin: 0 0 24px;
  color: var(--gw-on-surface-muted);
}

.gw-error-meta {
  display: inline-block;
  margin: 0 0 24px;
  padding: 8px 12px;
  background: var(--gw-surface-muted);
  border: 1px solid var(--gw-border);
  border-radius: var(--gw-rounded-md);
  color: var(--gw-on-surface-muted);
  font-size: var(--gw-text-body-sm);
  user-select: all;
}

/* ======================================================================
 * 관리 화면 공통 (01-07 목업 승인분: 직원·부서·직급·메뉴·역할·계정·감사 로그)
 * DESIGN.md Components의 list-table / pager / filter-bar / photo-frame / field-masked 등
 * ====================================================================== */

/* ---------- 입력 변형: 선택 상자 · 여러 줄 · 체크박스 · 스위치 · 오류 ---------- */
.form-select {
  --bs-form-select-bg-img: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23536175' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  min-height: var(--gw-row-height);
  padding: 0 36px 0 12px;
  border-color: var(--gw-border-strong);
  border-radius: var(--gw-rounded-md);
  background-color: var(--gw-surface);
  font-size: var(--gw-text-body-md);
}

.form-select:focus {
  border-color: var(--gw-primary);
  box-shadow: 0 0 0 3px rgba(var(--gw-primary-rgb), .25);
}

textarea.form-control {
  min-height: 96px;
  padding: 8px 12px;
}

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
  background-color: var(--gw-surface-muted);
  color: var(--gw-on-surface-muted);
}

.form-control.is-invalid:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gw-error) 25%, transparent);
}

.form-check-input {
  width: 18px;
  height: 18px;
  margin-top: 0;
  border-color: var(--gw-border-strong);
}

.form-check-input:focus {
  border-color: var(--gw-primary);
  box-shadow: 0 0 0 3px rgba(var(--gw-primary-rgb), .25);
}

.form-check-input:checked {
  background-color: var(--gw-primary);
  border-color: var(--gw-primary);
}

.form-switch .form-check-input {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%2364748B'/%3e%3c/svg%3e");
  width: 36px;
  height: 20px;
}

.form-switch .form-check-input:focus:not(:checked) {
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%2364748B'/%3e%3c/svg%3e");
}

.form-check-input:disabled {
  opacity: .5;
}

.form-text {
  font-size: var(--gw-text-body-sm);
}

/* ---------- 버튼 변형: 글자 단추 ---------- */
.btn-link {
  --bs-btn-padding-x: 8px;
  --bs-btn-font-weight: 600;
  --bs-btn-color: var(--gw-primary);
  --bs-btn-hover-color: var(--gw-primary-hover);
  text-decoration: none;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-link.gw-danger {
  --bs-btn-color: var(--gw-error);
  --bs-btn-hover-color: var(--gw-error);
}

.gw-icon-btn-sm {
  min-width: 32px;
  min-height: 32px;
}

/* ---------- 배지/보조 텍스트 ---------- */
.gw-badge-neutral .bi,
.gw-badge-info .bi,
.gw-badge-success .bi,
.gw-badge-warning .bi,
.gw-badge-error .bi {
  font-size: 11px;
}

/* ---------- 화면 머리 · 영역 · 폼 격자 ---------- */
.gw-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: var(--gw-space-md);
}

.gw-page-head .gw-page-title {
  margin: 0;
}

.gw-page-head p {
  margin: 4px 0 0;
}

.gw-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gw-space-sm);
}

.gw-section {
  margin-bottom: var(--gw-space-md);
  padding: var(--gw-space-lg);
  background: var(--gw-surface);
  border: 1px solid var(--gw-border);
  border-radius: var(--gw-rounded-lg);
  color: var(--gw-on-surface);
}

.gw-section-title {
  margin: 0 0 var(--gw-space-md);
  font-size: var(--gw-text-headline-sm);
  font-weight: 700;
  line-height: 1.4;
}

.gw-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: var(--gw-space-md);
}

.gw-form-grid > .gw-span-all {
  grid-column: 1 / -1;
}

.gw-form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--gw-space-sm);
}

/* ---------- 필터 바 (filter-bar) ---------- */
.gw-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px var(--gw-space-md);
  background: var(--gw-surface);
  border: 1px solid var(--gw-border);
  border-radius: var(--gw-rounded-md);
}

.gw-filter-field {
  display: flex;
  flex: 0 1 160px;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}

.gw-filter-field-grow {
  flex: 1 1 180px;
}

.gw-filter-field .form-label {
  margin: 0;
  color: var(--gw-on-surface-muted);
  font-size: var(--gw-text-caption);
  font-weight: 500;
}

.gw-filter-actions {
  display: flex;
  gap: var(--gw-space-sm);
  margin-left: auto;
}

/* ---------- 목록 확장: 정렬 · 선택 · 묶음 · 변경 표시 · 페이저 ---------- */
.gw-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.gw-sort .bi {
  font-size: 11px;
  opacity: .55;
}

.gw-list th[aria-sort] .gw-sort {
  color: var(--gw-primary);
}

.gw-list th[aria-sort] .gw-sort .bi {
  opacity: 1;
}

.gw-list a {
  text-decoration: none;
}

.gw-list a:hover {
  text-decoration: underline;
}

.gw-list td.gw-cell-num,
.gw-list th.gw-cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.gw-list td.gw-cell-actions {
  white-space: nowrap;
  text-align: right;
}

.gw-list tbody tr.is-selected td {
  background: var(--gw-primary-subtle);
}

.gw-list tr.gw-group-row td {
  height: 36px;
  background: var(--gw-surface-muted);
  color: var(--gw-secondary);
  font-weight: 600;
}

.gw-list tbody tr.gw-group-row:hover td {
  background: var(--gw-surface-muted);
}

.gw-list td.is-changed {
  background: var(--gw-primary-subtle);
}

.gw-list .form-check-input {
  margin: 0;
  vertical-align: middle;
}

.gw-list-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.gw-pager-info {
  color: var(--gw-on-surface-muted);
  font-size: var(--gw-text-body-sm);
}

.gw-pager-list {
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.gw-pager-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  background: var(--gw-surface);
  border: 1px solid var(--gw-border-strong);
  border-radius: var(--gw-rounded-md);
  color: var(--gw-secondary);
  font-size: var(--gw-text-body-sm);
  text-decoration: none;
}

.gw-pager-item:hover {
  background: var(--gw-surface-muted);
  color: var(--gw-on-surface);
}

.gw-pager-item.is-active {
  background: var(--gw-primary-subtle);
  border-color: var(--gw-primary);
  color: var(--gw-primary);
  font-weight: 600;
}

.gw-pager-item.is-disabled {
  opacity: .4;
  pointer-events: none;
}

/* ---------- 사진 칸 (photo-frame) ---------- */
.gw-photo-edit {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gw-space-md);
  align-items: flex-start;
}

.gw-photo-frame {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 160px;
  overflow: hidden;
  background: var(--gw-surface-muted);
  border: 1px solid var(--gw-border-strong);
  border-radius: var(--gw-rounded-md);
  color: var(--gw-on-surface-muted);
  font-size: 56px;
}

.gw-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gw-photo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--gw-space-sm);
}

/* ---------- 가려진 값 (field-masked) ---------- */
.gw-field-masked {
  display: flex;
  gap: var(--gw-space-sm);
}

.gw-field-masked-value {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  min-height: var(--gw-row-height);
  padding: 0 12px;
  background: var(--gw-surface-muted);
  border: 1px solid var(--gw-border);
  border-radius: var(--gw-rounded-md);
  color: var(--gw-on-surface-muted);
  letter-spacing: 2px;
}

/* ---------- 768px 미만 (컨테이너): 관리 화면 공통 ---------- */
@container gw (max-width: 767.98px) {
  .form-control,
  .form-select {
    min-height: var(--gw-touch-target);
    font-size: 16px;
  }

  textarea.form-control {
    min-height: 96px;
  }

  .gw-page-head {
    align-items: stretch;
  }

  .gw-page-actions {
    width: 100%;
  }

  .gw-page-actions .btn,
  .gw-form-actions .btn,
  .gw-filter-actions .btn {
    flex: 1;
    min-height: var(--gw-touch-target);
  }

  .gw-section {
    padding: var(--gw-space-md);
  }

  .gw-filter-field,
  .gw-filter-field-grow {
    flex: 1 1 100%;
  }

  .gw-filter-actions {
    width: 100%;
    margin-left: 0;
  }

  .gw-list td.gw-cell-title {
    display: block;
    min-height: 0;
    padding: 0 0 4px;
    font-size: var(--gw-text-headline-sm);
    font-weight: 700;
    text-align: left;
  }

  .gw-list td.gw-cell-title::before,
  .gw-list td:not([data-label])::before {
    content: none;
  }

  .gw-list td.gw-cell-empty {
    display: none;
  }

  .gw-list td.gw-cell-actions {
    justify-content: flex-end;
  }

  .gw-list tbody tr.is-selected {
    background: var(--gw-primary-subtle);
    border-color: var(--gw-primary);
  }

  .gw-list tbody tr.is-selected td {
    background: transparent;
  }

  .gw-list tr.gw-group-row {
    padding: 8px 4px 0;
    background: transparent;
    border: 0;
  }

  .gw-list tr.gw-group-row td {
    display: block;
    min-height: 0;
    height: auto;
    padding: 0;
    background: transparent;
    text-align: left;
  }

  .gw-list td.is-changed {
    margin: 0 -8px;
    padding: 4px 8px;
    border-radius: var(--gw-rounded-sm);
  }

  .gw-list-foot {
    justify-content: center;
  }

  .gw-pager-item {
    min-width: var(--gw-touch-target);
    height: var(--gw-touch-target);
  }

  .gw-photo-edit {
    flex-direction: column;
  }
}

/* ---------- 버튼: 위험 동작 (button-danger) ---------- */
.btn-danger {
  --bs-btn-color: var(--gw-surface);
  --bs-btn-bg: var(--gw-error);
  --bs-btn-border-color: var(--gw-error);
  --bs-btn-hover-color: var(--gw-surface);
  --bs-btn-hover-bg: color-mix(in srgb, var(--gw-error) 85%, #000);
  --bs-btn-hover-border-color: color-mix(in srgb, var(--gw-error) 85%, #000);
  --bs-btn-focus-shadow-rgb: 185, 28, 28;
  --bs-btn-active-color: var(--gw-surface);
  --bs-btn-active-bg: color-mix(in srgb, var(--gw-error) 85%, #000);
  --bs-btn-active-border-color: color-mix(in srgb, var(--gw-error) 85%, #000);
  --bs-btn-disabled-color: var(--gw-surface);
  --bs-btn-disabled-bg: var(--gw-error);
  --bs-btn-disabled-border-color: var(--gw-error);
}

/* ---------- 탭 (tabs): 한 화면 안의 구역 전환 ---------- */
.gw-tabs {
  display: flex;
  gap: 4px;
  margin: 0 0 var(--gw-space-md);
  padding: 0;
  overflow-x: auto;
  border-bottom: 1px solid var(--gw-border);
}

.gw-tabs-item {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 6px;
  min-height: var(--gw-row-height);
  margin-bottom: -1px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--gw-secondary);
  font-size: var(--gw-text-body-md);
  white-space: nowrap;
}

.gw-tabs-item:hover {
  color: var(--gw-on-surface);
}

.gw-tabs-item.is-active {
  border-bottom-color: var(--gw-primary);
  color: var(--gw-primary);
  font-weight: 600;
}

/* ---------- 키 칩 (key-chip) · 트리 (tree-row) ---------- */
.gw-key {
  display: inline-block;
  padding: 2px 8px;
  background: var(--gw-surface-muted);
  border: 1px solid var(--gw-border);
  border-radius: var(--gw-rounded-sm);
  color: var(--gw-secondary);
  font-size: var(--gw-text-caption);
  font-weight: 500;
  line-height: 1.4;
}

.gw-tree-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: calc(var(--depth, 0) * 24px);
}

.gw-tree-cell .bi {
  flex: none;
  color: var(--gw-secondary);
}

.gw-list td.gw-cell-check,
.gw-list th.gw-cell-check {
  width: 72px;
  text-align: center;
}

/* ---------- 권한 칩 · 범위 ---------- */
.gw-perm-set {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.gw-perm {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 8px;
  border-radius: var(--gw-rounded-sm);
  font-size: var(--gw-text-caption);
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.gw-perm .bi {
  font-size: 12px;
}

.gw-perm.is-on {
  background: var(--gw-primary-subtle);
  color: var(--gw-primary);
  font-weight: 600;
}

.gw-perm.is-off {
  border: 1px dashed var(--gw-border-strong);
  color: var(--gw-on-surface-muted);
}

.gw-perm-scope {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  color: var(--gw-secondary);
  font-size: var(--gw-text-caption);
}

/* ---------- 세그먼트 (segment) ---------- */
.gw-segment {
  position: relative;
  display: inline-flex;
  background: var(--gw-surface);
  border: 1px solid var(--gw-border-strong);
  border-radius: var(--gw-rounded-md);
  overflow: hidden;
}

.gw-segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.gw-segment label {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin: 0;
  padding: 0 12px;
  border-right: 1px solid var(--gw-border-strong);
  color: var(--gw-secondary);
  font-size: var(--gw-text-body-sm);
  white-space: nowrap;
  cursor: pointer;
}

.gw-segment label:last-of-type {
  border-right: 0;
}

.gw-segment input:checked + label {
  background: var(--gw-primary-subtle);
  color: var(--gw-primary);
  font-weight: 600;
}

.gw-segment input.is-deny:checked + label {
  background: var(--gw-error-subtle);
  color: var(--gw-error);
}

.gw-segment input:focus-visible + label {
  outline: 2px solid var(--gw-primary);
  outline-offset: -2px;
}

.gw-segment input:disabled + label {
  opacity: .5;
  cursor: not-allowed;
}

/* ---------- 변경 전/후 (diff-view) ---------- */
.gw-diff {
  background: var(--gw-surface);
  border: 1px solid var(--gw-border);
  border-radius: var(--gw-rounded-md);
  font-size: var(--gw-text-body-sm);
  overflow: hidden;
}

.gw-diff-head,
.gw-diff-row {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 2fr 2fr;
}

.gw-diff-head {
  background: var(--gw-surface-muted);
  color: var(--gw-on-surface-muted);
  font-size: var(--gw-text-label-md);
  font-weight: 600;
}

.gw-diff-head > *,
.gw-diff-row > * {
  min-width: 0;
  padding: 8px 12px;
  overflow-wrap: anywhere;
}

.gw-diff-row {
  border-top: 1px solid var(--gw-border);
}

.gw-diff-field {
  color: var(--gw-on-surface-muted);
  font-weight: 600;
}

.gw-diff-before.is-changed {
  background: var(--gw-error-subtle);
  color: var(--gw-error);
}

.gw-diff-after.is-changed {
  background: var(--gw-success-subtle);
  color: var(--gw-success);
}

.gw-diff-note {
  padding: 8px 12px;
  border-top: 1px solid var(--gw-border);
  color: var(--gw-on-surface-muted);
}

.gw-list td.gw-detail-cell {
  height: auto;
  padding: 12px 16px;
  background: var(--gw-surface-muted);
}

.gw-detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gw-space-sm);
  margin-top: 12px;
}

/* ---------- 모달 (modal = AppModal) ---------- */
.gw-modal {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--gw-space-md);
}

.gw-modal.is-open {
  display: flex;
}

.gw-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(var(--gw-on-surface-rgb), .45);
}

.gw-modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(480px, 100%);
  max-height: 100%;
  background: var(--gw-surface);
  border-radius: var(--gw-rounded-lg);
  box-shadow: 0 12px 32px rgba(var(--gw-on-surface-rgb), .22);
  color: var(--gw-on-surface);
}

.gw-modal-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  padding: 12px 8px 4px 24px;
}

.gw-modal-title {
  margin: 0;
  font-size: var(--gw-text-headline-sm);
  font-weight: 700;
}

.gw-modal-body {
  padding: 8px 24px 16px;
  overflow-y: auto;
}

.gw-modal-foot {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--gw-space-sm);
  padding: 12px 24px 20px;
  border-top: 1px solid var(--gw-border);
}

/* ---------- 임시 비밀번호 (secret-box) ---------- */
.gw-secret {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px var(--gw-space-md);
  background: var(--gw-surface-muted);
  border: 1px dashed var(--gw-border-strong);
  border-radius: var(--gw-rounded-md);
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 1px;
}

/* ---------- 계정 상세: 키-값 줄 ---------- */
.gw-kv {
  display: grid;
  grid-template-columns: minmax(96px, 160px) 1fr;
  gap: 8px var(--gw-space-md);
  margin: 0;
}

.gw-kv dt {
  color: var(--gw-on-surface-muted);
  font-weight: 600;
}

.gw-kv dd {
  margin: 0;
}

.gw-role-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gw-border);
}

.gw-role-option:last-child {
  border-bottom: 0;
}

.gw-role-option .form-check-input {
  flex: none;
  margin-top: 2px;
}

.gw-role-option label {
  font-weight: 600;
}

.gw-role-option p {
  margin: 2px 0 0;
}

@container gw (max-width: 767.98px) {
  .gw-tabs-item {
    min-height: var(--gw-touch-target);
  }

  .gw-segment {
    display: flex;
    flex-direction: column;
    width: 100%;
  }

  .gw-segment label {
    min-height: var(--gw-touch-target);
    border-right: 0;
    border-bottom: 1px solid var(--gw-border-strong);
  }

  .gw-segment label:last-of-type {
    border-bottom: 0;
  }

  .gw-diff-head {
    display: none;
  }

  .gw-diff-row {
    grid-template-columns: 1fr;
  }

  .gw-diff-row > * {
    padding: 6px 12px;
  }

  .gw-diff-before::before,
  .gw-diff-after::before {
    content: attr(data-label) " · ";
    font-weight: 600;
  }

  .gw-list td.gw-cell-check {
    width: auto;
    text-align: right;
  }

  .gw-list td.gw-cell-check .form-check-input {
    width: 24px;
    height: 24px;
  }

  .gw-list td .gw-perm-set,
  .gw-list td .gw-perm-wrap {
    justify-content: flex-end;
    text-align: right;
  }

  .gw-list td.gw-detail-cell {
    display: block;
    padding: 12px;
    text-align: left;
  }

  .gw-modal-body,
  .gw-modal-head {
    padding-right: 16px;
    padding-left: 16px;
  }

  .gw-modal-foot {
    padding: 12px 16px 16px;
  }

  .gw-modal-foot .btn {
    flex: 1;
    min-height: var(--gw-touch-target);
  }

  .gw-secret {
    font-size: 16px;
  }

  .gw-kv {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .gw-kv dd {
    margin-bottom: 10px;
  }
}

/* ---------- 관리 화면 보완: 동작 줄 · 2열 권한 칩 · 표 안 선택 상자 ---------- */
.gw-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gw-space-md);
  padding: 12px 0;
  border-bottom: 1px solid var(--gw-border);
}

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

.gw-action-row p {
  margin: 2px 0 0;
}

.gw-perm-set.is-2col {
  display: grid;
  grid-template-columns: repeat(2, max-content);
  gap: 4px;
}

.gw-list .form-select {
  min-height: 32px;
  height: 32px;
  padding: 0 28px 0 8px;
  background-position: right 8px center;
  font-size: var(--gw-text-body-sm);
}

.gw-list td.gw-cell-stack {
  height: auto;
  padding-top: 8px;
  padding-bottom: 8px;
  vertical-align: top;
}

@container gw (max-width: 767.98px) {
  .gw-action-row {
    align-items: stretch;
    flex-direction: column;
  }

  .gw-action-row .btn {
    min-height: var(--gw-touch-target);
  }

  .gw-icon-btn-sm {
    min-width: var(--gw-touch-target);
    min-height: var(--gw-touch-target);
  }

  .gw-list .form-select {
    height: auto;
    min-height: var(--gw-touch-target);
    font-size: 16px;
  }

  .gw-perm-set.is-2col {
    grid-template-columns: repeat(2, max-content);
    justify-content: end;
  }
}

.gw-list td.gw-cell-title .btn-link {
  --bs-btn-font-size: inherit;
  --bs-btn-font-weight: inherit;
}

@container gw (max-width: 767.98px) {
  .gw-perm-wrap .gw-perm-scope {
    justify-content: flex-end;
  }
}
