/* ============================================================
 * common.css — MSO관리팀 업무지원 시스템 공통 스타일
 * 전면 재작성 (2026-06)
 * 기존 2,756줄 → 정리·통합·중복 제거
 * ============================================================ */

@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/static/pretendard.css");

/* ─────────────────────────────────────────────────────────────
 * 1. 디자인 토큰
 * ───────────────────────────────────────────────────────────── */
:root {
  /* 색상 — 브랜드 */
  --navy:          #0b1630;
  --navy-soft:     #13203f;
  --navy-muted:    #1e3260;
  --blue:          #2f6df6;
  --blue-soft:     #eaf1ff;
  --blue-mid:      #dbeafe;

  /* 색상 — 배경 */
  --bg:            #f0f2f5;
  --surface:       #ffffff;
  --surface-soft:  #f8fafc;
  --surface-hover: #f4f7fb;

  /* 색상 — 텍스트 */
  --text-primary:   #111827;
  --text-secondary: #4b5563;
  --text-muted:     #9ca3af;
  --text-disabled:  #d1d5db;

  /* 색상 — 테두리 */
  --border:        #e5e7eb;
  --border-soft:   #f3f4f6;
  --border-input:  #d1d5db;
  --border-focus:  #2f6df6;

  /* 색상 — 시맨틱 */
  --success-bg:    #f0fdf4;
  --success-text:  #166534;
  --success-border:#bbf7d0;

  --warning-bg:    #fffbeb;
  --warning-text:  #92400e;
  --warning-border:#fde68a;

  --info-bg:       #eff6ff;
  --info-text:     #1e40af;
  --info-border:   #bfdbfe;

  --danger-bg:     #fef2f2;
  --danger-text:   #991b1b;
  --danger-border: #fecaca;

  /* 색상 — 상태 뱃지 */
  --status-inuse-bg:      #f0fdf4;
  --status-inuse-text:    #166534;
  --status-inuse-border:  #bbf7d0;

  --status-repair-bg:     #fff7ed;
  --status-repair-text:   #9a3412;
  --status-repair-border: #fed7aa;

  --status-inspect-bg:    #eff6ff;
  --status-inspect-text:  #1e40af;
  --status-inspect-border:#bfdbfe;

  --status-stored-bg:     #f9fafb;
  --status-stored-text:   #374151;
  --status-stored-border: #e5e7eb;

  --status-disposed-bg:   #fef2f2;
  --status-disposed-text: #991b1b;
  --status-disposed-border:#fecaca;

  /* 반경 */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl:20px;

  /* 그림자 */
  --shadow-xs:   0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg:   0 10px 30px rgba(0,0,0,0.10), 0 4px 8px rgba(0,0,0,0.04);
  --shadow-modal:0 20px 60px rgba(0,0,0,0.16), 0 8px 16px rgba(0,0,0,0.06);

  /* 타이포 */
  --font-base: "Pretendard", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --fs-xs:   11px;
  --fs-sm:   12px;
  --fs-base: 13px;
  --fs-md:   14px;
  --fs-lg:   15px;
  --fs-xl:   16px;
  --fs-2xl:  18px;
  --fs-3xl:  20px;
  --fs-4xl:  24px;

  /* 간격 */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;

  /* 레이아웃 */
  --container-max: 1280px;
  --content-pad:   24px;

  /* 트랜지션 */
  --transition: 0.15s ease;
}

/* ─────────────────────────────────────────────────────────────
 * 2. 리셋 & 베이스
 * ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: var(--font-base);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }
h1,h2,h3,h4,h5,h6 { margin: 0; font-weight: 700; line-height: 1.3; }
p { margin: 0; }

/* ─────────────────────────────────────────────────────────────
 * 3. 레이아웃
 * ───────────────────────────────────────────────────────────── */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--content-pad);
}

.page-shell {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--sp-5) var(--content-pad) var(--sp-8);
}

.grid   { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.full-col { grid-column: 1 / -1; }
.two-col  { grid-column: span 2; }
.is-hidden { display: none !important; }

/* ─────────────────────────────────────────────────────────────
 * 4. 카드
 * ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.card-body {
  padding: var(--sp-5);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
}

/* ─────────────────────────────────────────────────────────────
 * 5. 타이포그래피
 * ───────────────────────────────────────────────────────────── */
.page-title {
  font-size: var(--fs-4xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.section-title {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.page-desc,
.sub-text {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.55;
}

.text-muted   { color: var(--text-muted); }
.text-primary { color: var(--text-primary); }
.required     { color: #dc2626; }

/* ─────────────────────────────────────────────────────────────
 * 6. 버튼
 * ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-input);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), box-shadow var(--transition);
  text-decoration: none;
  line-height: 1;
}

.btn:hover {
  background: var(--surface-hover);
  border-color: #b0b8c4;
}

.btn:active { transform: scale(0.98); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn i { font-size: 15px; }

/* 버튼 변형 */
.btn-primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.btn-primary:hover {
  background: var(--navy-soft);
  border-color: var(--navy-soft);
  color: #fff;
}

.btn-warning {
  background: #f59e0b;
  color: #fff;
  border-color: #f59e0b;
}
.btn-warning:hover {
  background: #d97706;
  border-color: #d97706;
  color: #fff;
}

.btn-blue {
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}
.btn-blue:hover {
  background: #2460e0;
  border-color: #2460e0;
  color: #fff;
}

.btn-danger {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}
.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}

.btn-success {
  background: #16a34a;
  color: #fff;
  border-color: #16a34a;
}
.btn-success:hover {
  background: #15803d;
  border-color: #15803d;
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--surface-soft);
  color: var(--text-primary);
  border-color: transparent;
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
}

.btn-lg {
  height: 42px;
  padding: 0 20px;
  font-size: var(--fs-md);
}

.btn-card-action {
  height: 30px;
  padding: 0 10px;
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
}

/* ─────────────────────────────────────────────────────────────
 * 7. 폼 요소
 * ───────────────────────────────────────────────────────────── */

/* 공통 인풋/셀렉트 기반 */
.input,
.form-input,
.form-control,
.form-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="search"],
select.input,
textarea.input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--fs-base);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.input:hover,
.form-input:hover,
.form-control:hover,
.form-select:hover {
  border-color: #9ca3af;
}

.input:focus,
.form-input:focus,
.form-control:focus,
.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(47, 109, 246, 0.12);
}

.input::placeholder,
.form-input::placeholder { color: var(--text-muted); }

/* select 화살표 */
select.input,
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239ca3af' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

/* textarea */
textarea.input,
.textarea {
  height: auto;
  min-height: 80px;
  padding: 8px 10px;
  resize: vertical;
  line-height: 1.55;
}

/* 작은 인풋 */
.input-sm,
.input--sm {
  height: 28px;
  padding: 0 8px;
  font-size: var(--fs-sm);
}

/* form-field: 라벨 + 인풋 세트 */
.form-field,
.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label,
.field-group label,
.form-field label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-help {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  line-height: 1.4;
}

/* form-group: 여러 form-field 묶음 */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
}

.form-grid {
  display: grid;
  gap: var(--sp-3);
}

/* form-section: 폼 내 섹션 구분 */
.form-section {
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border-soft);
}
.form-section:first-child { padding-top: 0; border-top: none; }

.form-section-label {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--sp-3);
}

/* form-actions: 폼 하단 버튼 영역 */
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-soft);
  margin-top: var(--sp-4);
}

/* 에러 상태 */
.is-invalid .input,
.is-invalid .form-input,
.is-field-error .input {
  border-color: #dc2626;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.10);
}

.field-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--blue-soft);
  color: var(--blue);
}

.form-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 5px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.form-tab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ─────────────────────────────────────────────────────────────
 * 8. 테이블
 * ───────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  font-size: var(--fs-base);
}

.data-table th,
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  background: var(--surface-soft);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table tbody tr:last-child td { border-bottom: none; }

.data-table tbody tr:hover { background: var(--surface-soft); }

.data-table .th-center,
.data-table td.center { text-align: center; }

.data-table .th-right,
.data-table td.right { text-align: right; }

/* ─────────────────────────────────────────────────────────────
 * 9. 뱃지 & 상태
 * ───────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
  background: var(--surface-soft);
  color: var(--text-secondary);
  border-color: var(--border);
}

.badge-blue   { background: var(--info-bg);    color: var(--info-text);    border-color: var(--info-border); }
.badge-green  { background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.badge-yellow { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }
.badge-red    { background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger-border); }
.badge-navy   { background: var(--navy);       color: #fff;                border-color: var(--navy); }

/* 상태 뱃지 (장비) */
.status-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 700;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-badge.is-in-use {
  background: var(--status-inuse-bg);
  color: var(--status-inuse-text);
  border-color: var(--status-inuse-border);
}
.status-badge.is-repairing {
  background: var(--status-repair-bg);
  color: var(--status-repair-text);
  border-color: var(--status-repair-border);
}
.status-badge.is-inspecting {
  background: var(--status-inspect-bg);
  color: var(--status-inspect-text);
  border-color: var(--status-inspect-border);
}
.status-badge.is-stored {
  background: var(--status-stored-bg);
  color: var(--status-stored-text);
  border-color: var(--status-stored-border);
}
.status-badge.is-disposed {
  background: var(--status-disposed-bg);
  color: var(--status-disposed-text);
  border-color: var(--status-disposed-border);
}

/* 태그 */
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-xs);
  font-size: var(--fs-xs);
  font-weight: 600;
  background: var(--surface-soft);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

/* ─────────────────────────────────────────────────────────────
 * 10. 메시지 & 알림
 * ───────────────────────────────────────────────────────────── */
.message-box {
  display: none;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  line-height: 1.5;
  border: 1px solid transparent;
  margin-bottom: var(--sp-4);
}

.message-box.info    { display: block; background: var(--info-bg);    color: var(--info-text);    border-color: var(--info-border); }
.message-box.success { display: block; background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.message-box.error   { display: block; background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger-border); }
.message-box.warning { display: block; background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-border); }

/* ─────────────────────────────────────────────────────────────
 * 11. 빈 상태
 * ───────────────────────────────────────────────────────────── */
.empty-state,
.empty-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: var(--sp-6);
  text-align: center;
  border: 1px dashed var(--border-input);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
  color: var(--text-muted);
}

.empty-state i { font-size: 32px; margin-bottom: var(--sp-3); }

.empty-state-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
}

.empty-state-desc {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─────────────────────────────────────────────────────────────
 * 12. KPI 카드
 * ───────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: var(--sp-3);
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4) var(--sp-4);
}

.kpi-label {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--sp-2);
}

.kpi-value {
  font-size: var(--fs-4xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.kpi-sub {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

/* ─────────────────────────────────────────────────────────────
 * 13. 페이지 헤더 (기존 topbar — Shell SPA에서는 숨겨짐)
 * ───────────────────────────────────────────────────────────── */
.top-brand-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 14px var(--sp-5);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}

.top-brand-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.top-brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #22c55e, #2563eb);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  flex-shrink: 0;
}

.top-brand-texts {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.top-brand-title {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}

.top-brand-sub {
  font-size: var(--fs-md);
  color: var(--text-secondary);
}

.top-brand-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* portal-page 공통 topbar */
.portal-page { }

.portal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.portal-top-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
  flex-wrap: wrap;
}

.portal-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-input);
  background: var(--surface);
  color: var(--text-primary);
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition);
  text-decoration: none;
}

.portal-header-btn:hover {
  background: var(--surface-hover);
  border-color: #9ca3af;
}

.portal-header-btn--primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}
.portal-header-btn--primary:hover {
  background: var(--navy-soft);
  border-color: var(--navy-soft);
  color: #fff;
}

.portal-header-btn--secondary {
  background: var(--surface);
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────────────────────
 * 14. 포털 레이아웃
 * ───────────────────────────────────────────────────────────── */
.portal-section       { margin-top: var(--sp-6); }
.portal-section-kicker {
  display: inline-block;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: var(--sp-2);
}
.portal-section-title { font-size: var(--fs-3xl); font-weight: 700; }
.portal-section-desc  { font-size: var(--fs-base); color: var(--text-secondary); margin-top: 4px; }

.portal-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.portal-group-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

/* 포털 앱 그리드 */
.portal-app-grid,
.portal-app-grid-compact {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: var(--sp-3);
}

.portal-app-card-compact {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.portal-app-card-compact:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow-sm);
}

.portal-app-card-compact--muted { opacity: 0.5; }
.portal-app-card-compact--disabled { cursor: not-allowed; opacity: 0.4; }

.portal-app-card-compact__icon {
  font-size: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
  width: 32px;
  text-align: center;
}

.portal-app-card-compact__title {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.portal-app-card-compact__fav {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 2px 4px;
  border-radius: var(--radius-xs);
  transition: color var(--transition);
  line-height: 1;
  flex-shrink: 0;
}
.portal-app-card-compact__fav:hover { color: #f59e0b; }
.portal-app-card-compact__fav--active { color: #f59e0b; }

.portal-hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
}

.portal-intro {
  display: grid;
  grid-template-columns: minmax(0,1.4fr) minmax(260px,380px);
  gap: var(--sp-4);
  align-items: stretch;
  margin-top: var(--sp-5);
}

.portal-intro-main,
.portal-profile-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  padding: var(--sp-5);
}

.portal-profile-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.portal-profile-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: var(--sp-2);
}

.portal-user-name { font-size: var(--fs-2xl); font-weight: 700; color: var(--text-primary); }
.portal-user-sub  { font-size: var(--fs-base); color: var(--text-secondary); margin-top: 6px; line-height: 1.5; }
.portal-user-box  { margin-left: auto; text-align: right; }

/* portal-page-compact (기존 호환) */
.portal-page-compact .portal-top-actions-compact {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.portal-page-compact .portal-header-userline {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}
.portal-page-compact .portal-header-username { color: var(--text-primary); font-weight: 700; }
.portal-page-compact .portal-header-usersep  { color: var(--border-input); }
.portal-page-compact .portal-section-head--compact {
  margin-bottom: var(--sp-4);
}
.portal-page-compact .portal-section-head--compact > div {
  position: relative;
  padding-left: 14px;
}
.portal-page-compact .portal-section-head--compact > div::before {
  content: "";
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  border-radius: 999px;
  background: var(--blue);
}
.portal-page-compact .portal-section-head--compact .portal-section-title {
  font-size: var(--fs-4xl);
  letter-spacing: -0.02em;
}

/* ─────────────────────────────────────────────────────────────
 * 15. 검색 / 필터 영역
 * ───────────────────────────────────────────────────────────── */
.search-bar,
.search-main-row {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-end;
  flex-wrap: wrap;
}

.search-field,
.search-label { }

.search-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.search-keyword-wrap   { flex: 1 1 180px; min-width: 0; }
.search-keyword-group  { flex: 1 1 180px; min-width: 0; }
.search-select         { min-width: 100px; }
.search-date-input     { width: 140px; }
.search-range-sep      { font-size: var(--fs-sm); color: var(--text-muted); padding-bottom: 7px; }
.search-reset-btn      { flex-shrink: 0; }
.search-result-head    { margin-top: var(--sp-3); }

/* 필터 칩 */
.filter-chip {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-input);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.filter-chip:hover { background: var(--surface-hover); border-color: #9ca3af; }
.filter-chip.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.search-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

.search-filter-block { margin-top: var(--sp-4); }
.search-action-block {
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px dashed var(--border);
}
.search-block-label {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-2);
  display: block;
}

/* 필터 액션 영역 */
.filter-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
  flex-wrap: wrap;
}
.filter-actions-left,
.filter-actions-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ─────────────────────────────────────────────────────────────
 * 16. 페이지네이션
 * ───────────────────────────────────────────────────────────── */
.pagination-area {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-1);
  padding: var(--sp-5) 0; /* margin-top만 있으면 버튼 위쪽엔 여백이 생기지만 아래쪽은
                             카드 바닥 테두리에 그대로 붙어버린다 — 위아래 대칭으로 패딩을 준다 */
  flex-wrap: wrap;
  min-height: 72px; /* 비어있어도(1페이지뿐이라 버튼이 없을 때도) 항상 이 높이를 차지해야
                        그리드 컨테이너의 가용 높이가 페이지 수와 무관하게 일정해진다.
                        (안 그러면 조회 결과가 여러 페이지로 늘어나는 순간 그리드 박스가
                        갑자기 줄어들면서 이미 계산된 pageSize와 어긋나 스크롤/컬럼폭 문제가 생김) */
  box-sizing: border-box;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}
.pagination-btn:hover { background: var(--surface-hover); }
.pagination-btn.is-active {
  background: var(--info-bg);
  border-color: var(--info-border);
  color: var(--info-text);
}
.pagination-btn:disabled { opacity: 0.4; cursor: default; }

/* ─────────────────────────────────────────────────────────────
 * 17. 모달
 * ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
}

.modal-container {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  line-height: 1;
  display: flex;
  align-items: center;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--surface-soft); color: var(--text-primary); }

.modal-body {
  padding: var(--sp-5);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
  flex-shrink: 0;
}

.modal-footer .btn { min-width: 80px; }

.modal-feedback {
  display: none;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  border: 1px solid transparent;
  margin-bottom: var(--sp-3);
}
.modal-feedback.is-success { display: block; background: var(--success-bg); color: var(--success-text); border-color: var(--success-border); }
.modal-feedback.is-error   { display: block; background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger-border); }

/* ─────────────────────────────────────────────────────────────
 * 18. 스켈레톤
 * ───────────────────────────────────────────────────────────── */
.skeleton,
.sk {
  position: relative;
  overflow: hidden;
  background: #e9ecef;
  border-radius: var(--radius-sm);
}
.skeleton::after,
.sk::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.6) 50%, transparent 100%);
  animation: skeleton-sweep 1.4s ease infinite;
}
@keyframes skeleton-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.sk-text-sm { height: 12px; margin-bottom: 6px; border-radius: var(--radius-xs); }
.sk-badge   { height: 20px; width: 60px; border-radius: var(--radius-sm); }

/* ─────────────────────────────────────────────────────────────
 * 19. 글로벌 로딩
 * ───────────────────────────────────────────────────────────── */
#globalLoading {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 99999;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}
#globalLoading.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
}
#globalLoading .global-loading__dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-6) var(--sp-8);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow-modal);
  min-width: 160px;
  text-align: center;
}
#globalLoading .global-loading__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
#globalLoading .global-loading__text {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--text-secondary);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─────────────────────────────────────────────────────────────
 * 20. 인포 타일 / 가이드
 * ───────────────────────────────────────────────────────────── */
.info-tile {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
}
.info-tile-wide { grid-column: 1 / -1; }
.info-tile-label { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: 4px; }
.info-tile-value { font-size: var(--fs-md); font-weight: 600; color: var(--text-primary); word-break: break-word; }

.guide-item {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
}
.guide-title { font-size: var(--fs-md); font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.guide-text  { font-size: var(--fs-sm); color: var(--text-secondary); line-height: 1.55; }

/* ─────────────────────────────────────────────────────────────
 * 21. 장비 라벨 프린트
 * ───────────────────────────────────────────────────────────── */
.device-label {
  width: 440px;
  min-height: 270px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--sp-5);
  display: grid;
  grid-template-columns: minmax(0,1fr) 152px;
  gap: var(--sp-4);
  align-items: center;
}
.label-hospital { font-size: var(--fs-md); font-weight: 700; color: var(--navy); margin-bottom: var(--sp-2); }
.label-title    { font-size: var(--fs-4xl); font-weight: 700; color: var(--text-primary); margin-bottom: var(--sp-3); word-break: break-word; }
.label-info-block { display: flex; flex-direction: column; gap: var(--sp-2); }
.label-row      { display: grid; grid-template-columns: 72px 1fr; gap: var(--sp-2); align-items: start; }
.label-key      { font-size: var(--fs-sm); font-weight: 700; color: var(--text-secondary); }
.label-value    { font-size: var(--fs-md); font-weight: 600; color: var(--text-primary); word-break: break-word; }
.label-qr-box   {
  width: 144px; min-height: 144px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-2);
}

/* ─────────────────────────────────────────────────────────────
 * 22. 어드민 레이아웃
 * ───────────────────────────────────────────────────────────── */
.admin-page-wrap,
.logs-page {
  max-width: 1440px;
  margin-left: auto;
  margin-right: auto;
}

/* ─────────────────────────────────────────────────────────────
 * 23. 페이지 히어로 (헤더 영역)
 * ───────────────────────────────────────────────────────────── */
.page-hero-simple {
  margin-bottom: var(--sp-5);
}

/* ─────────────────────────────────────────────────────────────
 * 24. 요약 카드 (summary-pill)
 * ───────────────────────────────────────────────────────────── */
.summary-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-4);
}
.summary-pill-label { font-size: var(--fs-sm); color: var(--text-secondary); margin-bottom: var(--sp-1); display: block; }
.summary-pill-value { font-size: var(--fs-4xl); font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }

/* ─────────────────────────────────────────────────────────────
 * 25. 컨텍스트 칩
 * ───────────────────────────────────────────────────────────── */
.list-context-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--info-bg);
  color: var(--info-text);
  font-size: var(--fs-xs);
  font-weight: 700;
  line-height: 1;
}
.list-context-chip.is-hidden { display: none; }

/* ─────────────────────────────────────────────────────────────
 * 26. 공지 모달 (portal)
 * ───────────────────────────────────────────────────────────── */
.notice-modal__close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
}
.notice-modal__close:hover { background: var(--surface-soft); }

.notice-modal__dismiss {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.portal-notice-row__close {
  background: none;
  border: none;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-xs);
}

/* ─────────────────────────────────────────────────────────────
 * 27. 모바일 반응형
 * ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  :root {
    --content-pad: 16px;
  }

  .page-shell {
    padding: var(--sp-4) var(--sp-4) var(--sp-6);
  }

  /* topbar */
  .top-brand-bar {
    display: block;
    padding: var(--sp-4);
    border-radius: var(--radius-xl);
    margin-bottom: var(--sp-4);
  }
  .top-brand-left  { width: 100%; }
  .top-brand-title { font-size: var(--fs-xl); }
  .top-brand-sub   { display: block; margin-top: 4px; font-size: var(--fs-sm); white-space: normal; }
  .top-brand-actions,
  .portal-top-actions {
    width: 100%;
    margin-top: var(--sp-3);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
    margin-left: 0;
  }
  .top-brand-actions.top-actions--cols-1,
  .portal-top-actions.top-actions--cols-1 { grid-template-columns: 1fr; }
  .top-brand-actions.top-actions--cols-3,
  .portal-top-actions.top-actions--cols-3 { grid-template-columns: repeat(3, 1fr); }

  .portal-header-btn {
    width: 100%;
    justify-content: center;
    height: 40px;
  }

  /* 그리드 */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .two-col { grid-column: auto; }

  /* 포털 */
  .portal-intro { grid-template-columns: 1fr; }
  .portal-app-grid,
  .portal-app-grid-compact { grid-template-columns: 1fr; }

  /* 페이지 compact topbar */
  .portal-page-compact .portal-top-actions-compact {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-2);
  }
  .portal-page-compact .portal-header-userline {
    grid-column: 1 / -1;
    justify-content: center;
    height: 40px;
  }

  /* 모달 */
  .modal-container { max-width: 100%; max-height: 95vh; }
  .modal-footer    { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; justify-content: center; }

  /* form-row */
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ─────────────────────────────────────────────────────────────
 * 28. Shell SPA 내부 iframe 페이지 스타일
 * (URL에 ?shell=1 파라미터가 있을 때 JS로 body.in-shell 클래스 추가)
 * ───────────────────────────────────────────────────────────── */

/* topbar 숨김 */
body.in-shell .top-brand-bar,
body.in-shell .portal-topbar,
body.in-shell .portal-page > .container > .top-brand-bar {
  display: none !important;
}

/* container 상단 패딩 축소 */
body.in-shell .container,
body.in-shell .page-shell {
  padding-top: var(--sp-4);
}

/* page-shell 최대폭 해제 (iframe이 너비를 관리) */
body.in-shell .page-shell,
body.in-shell .admin-page-wrap,
body.in-shell .logs-page {
  max-width: none;
}

/* 스크롤 허용 */
body.in-shell {
  overflow-y: auto;
  height: auto;
  min-height: 100vh;
}

/* ─────────────────────────────────────────────────────────────
 * 29. 하위 호환 변수 별칭
 * 기존 페이지별 CSS가 참조하는 구 변수명 → 새 토큰으로 매핑
 * common.css 교체 시 페이지별 CSS를 수정하지 않아도 되게 함
 * ───────────────────────────────────────────────────────────── */
:root {
  /* 테두리 */
  --border-card:   #e5e7eb;
  --border-dashed: #d1d5db;

  /* 그림자 */
  --shadow-card:       0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-card-hover: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);

  /* 블루 계열 */
  --blue-50:   #eaf1ff;

  /* 통계 페이지 전용 */
  --blue-50:   #eaf1ff;
}

/* ════════════════════════════════════════════
   m-modal — 공통 모달 컴포넌트
════════════════════════════════════════════ */
.m-modal {
  display: none; position: fixed; inset: 0; z-index: 500;
  align-items: center; justify-content: center;
}
.m-modal.is-open { display: flex; }
.m-modal-backdrop { position: absolute; inset: 0; background: rgba(11,22,48,0.45); }
.m-modal-dialog {
  position: relative; z-index: 1; background: #fff; border-radius: 8px;
  max-width: calc(100vw - 32px); max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.16); border: 1px solid #e5e7eb; overflow: hidden;
}
/* width는 각 페이지 인라인 style로 지정 */
.m-modal .m-modal-dialog--wide { width: calc(100vw - 48px); max-width: 1200px; height: calc(100vh - 80px); }
.m-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: #0b1630; flex-shrink: 0;
}
.m-modal-title { font-size: 13px; font-weight: 700; color: #fff; }
.m-modal-close {
  width: 24px; height: 24px; border: none; background: rgba(255,255,255,0.08);
  border-radius: 4px; color: rgba(255,255,255,0.6); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.m-modal-close:hover { background: rgba(255,255,255,0.15); color: #fff; }
.m-modal-body {
  flex: 1; overflow-y: auto; padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.m-modal-foot {
  display: flex; justify-content: flex-end; gap: 6px;
  padding: 8px 14px 10px; border-top: 1px solid #f3f4f6; background: #f8fafc; flex-shrink: 0;
}
.m-field { display: flex; flex-direction: column; gap: 4px; }
.m-field label { font-size: 11px; font-weight: 600; color: #4b5563; }
.m-field input, .m-field select {
  height: 32px; border: 1px solid #d1d5db; border-radius: 6px;
  padding: 0 8px; font-size: 12px; outline: none; transition: border-color 0.15s;
  background: #fff;
}
.m-field input:focus, .m-field select:focus { border-color: #3b82f6; }
.m-field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.m-req { color: #ef4444; }
.m-empty { padding: 32px; text-align: center; font-size: 12px; color: #9ca3af; }
