/* =========================================================
   APPLICATION PAGE COMPONENTS — Single Source of Truth
   -------------------------------------------------------------------------
   일반 관리화면의 외곽/상단 타이틀/검색카드/액션 정본.
   각 업무 모듈은 배치·컬럼·업무 전용 상태만 정의하고 이 표면을 재정의하지 않는다.
   ========================================================= */

:root{
  --app-page-gap: 14px;
  --app-page-title-size: 20px;
  --app-page-title-color: #10233f;
  --app-page-subtitle-color: #64748b;
  --app-page-surface: #fff;
  --app-page-line: #d6e2f2;
  --app-page-line-soft: #d9e7f5;
  --app-page-accent: #2563eb;
  --app-page-radius: 8px;
  --app-list-control-height: var(--ui-control-height, 44px);
}

/* 페이지 내부 wrapper는 폭을 소유하지 않는다. 실제 폭의 정본은 .app-layout-shell 이다. */
.app-page{
  width:100% !important;
  max-width:none !important;
  min-width:0 !important;
  margin:0 !important;
  padding:0 0 40px !important;
  display:flex !important;
  flex-direction:column !important;
  gap:var(--app-page-gap) !important;
  box-sizing:border-box;
}
.app-page > *{min-width:0;max-width:100%;box-sizing:border-box;}

/* 공용 header를 생략하는 embed 문서는 창 안쪽 여백만 공통으로 가진다. */
body.is-embed > .app-page,
body.estimate-popup-body > .app-page,
body.is-popup-records > .app-page{
  padding:12px !important;
}
@media(max-width:760px){
  body.is-embed > .app-page,
  body.estimate-popup-body > .app-page,
  body.is-popup-records > .app-page{padding:8px !important;}
}

/* 상단 타이틀 카드 */
.app-page-header{
  width:100% !important;
  max-width:none !important;
  min-height:86px !important;
  margin:0 !important;
  padding:14px 18px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:space-between !important;
  gap:14px !important;
  border:1px solid var(--app-page-line) !important;
  border-left:4px solid var(--app-page-accent) !important;
  border-radius:var(--app-page-radius) !important;
  background:var(--app-page-surface) !important;
  box-shadow:none !important;
  box-sizing:border-box;
}
.app-page-header > :first-child{
  flex:1 1 auto;
  min-width:0;
}
.app-page-header .app-page-title,
.app-page-header > :first-child > h1,
.app-page-header > :first-child > h2{
  width:fit-content;
  max-width:100%;
  margin:0;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  box-shadow:none;
  color:var(--app-page-title-color);
  font-size:var(--app-page-title-size);
  line-height:1.25;
  font-weight:800;
  letter-spacing:-.035em;
  word-break:keep-all;
}
.app-page-title-group{
  min-width:0;
}
.app-page-title-group > span:first-child{
  display:block;
  margin:0;
  color:var(--app-page-title-color);
  font-size:var(--app-page-title-size);
  line-height:1.25;
  font-weight:800;
  letter-spacing:-.035em;
}
.app-page-title-group > small{
  display:block;
  margin-top:7px;
  color:var(--app-page-subtitle-color);
  font-size:13px;
  line-height:1.5;
  font-weight:700;
}
.app-page-header .app-page-subtitle,
.app-page-header > :first-child > p:not(.app-page-eyebrow){
  margin:7px 0 0;
  color:var(--app-page-subtitle-color);
  font-size:13px;
  line-height:1.5;
  font-weight:700;
}
.app-page-eyebrow{
  margin:0 0 6px !important;
  color:var(--app-page-accent) !important;
  font-size:11px !important;
  line-height:1.2 !important;
  font-weight:800 !important;
  letter-spacing:.04em !important;
}
.app-page-actions{
  flex:0 1 auto;
  min-width:0;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  flex-wrap:wrap;
  gap:7px;
  margin:0;
}
.app-page-actions > :where(.btn,button,a,form){flex:0 0 auto;}
.app-page-actions form{margin:0;}

/* 상단 고정 액션 헤더
   - 긴 일반 페이지: topbar 바로 아래에서만 고정
   - 헤더 없는 팝업: 창 상단 8px에서 고정
   - 목록/대시보드처럼 짧은 화면에는 이 클래스를 붙이지 않는다. */
.app-sticky-header{
  position:sticky !important;
  z-index:140 !important;
  isolation:isolate;
  box-shadow:0 4px 12px rgba(30,66,110,.08) !important;
}
.app-sticky-header--page{
  top:var(--app-sticky-page-offset,80px) !important;
}
.app-sticky-header--popup{
  top:var(--app-sticky-popup-offset,8px) !important;
}
/* 모바일 일반 페이지에서는 큰 제목카드가 화면을 과도하게 차지하지 않게 고정을 해제한다.
   팝업은 닫기 버튼 접근성이 더 중요하므로 계속 고정한다. */
@media(max-width:760px){
  .app-sticky-header--page{
    position:relative !important;
    top:auto !important;
    z-index:auto !important;
    box-shadow:none !important;
  }
}

@media print{
  .app-sticky-header{
    position:static !important;
    top:auto !important;
    box-shadow:none !important;
  }
}

/* 제목 카드 안에 추가 업무 패널이 함께 있는 경우 outer 카드만 표면을 소유한다. */
.app-page-header-card{
  width:100% !important;
  max-width:none !important;
  margin:0 !important;
  padding:0 !important;
  overflow:hidden;
  border:1px solid var(--app-page-line) !important;
  border-left:4px solid var(--app-page-accent) !important;
  border-radius:var(--app-page-radius) !important;
  background:var(--app-page-surface) !important;
  box-shadow:none !important;
}
.app-page-header-card > .app-page-header{
  min-height:86px !important;
  padding:14px 18px !important;
  border:0 !important;
  border-left:0 !important;
  border-radius:0 !important;
  background:transparent !important;
}

/* 검색/필터 카드 표면. 내부 grid는 각 도메인 CSS가 담당한다. */
.app-filter-card{
  width:100% !important;
  max-width:none !important;
  margin:0 !important;
  border:1px solid var(--app-page-line-soft) !important;
  border-radius:var(--app-page-radius) !important;
  background:#fff !important;
  box-shadow:none !important;
}
.app-filter-card > form,
.app-filter-card > .card-body > form{
  min-width:0;
  max-width:100%;
}
.app-filter-card :where(.input,select,textarea){
  border-color:#dbe6f3;
  box-shadow:none;
}

/* 일반 섹션 카드의 공통 표면. 도메인은 내부 배치만 확장한다. */
.app-section-card{
  width:100% !important;
  max-width:none !important;
  margin-left:0 !important;
  margin-right:0 !important;
  border:1px solid var(--app-page-line-soft) !important;
  border-radius:var(--app-page-radius) !important;
  background:#fff !important;
  box-shadow:none !important;
}

/* 공용 관리목록 행: 제목/정보칸/행 액션의 높이와 기준선을 한 곳에서 관리한다. */
.app-list-row-card{
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:end;
  gap:16px;
  min-width:0;
}
.app-list-row-main{min-width:0;}
.app-list-row-title{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:7px;
  min-width:0;
}
.app-record-info-grid{
  display:grid;
  gap:0;
  min-width:0;
  border:1px solid #e2e8f0;
  border-radius:var(--app-page-radius);
  overflow:hidden;
  background:#f8fafc;
}
.app-record-info-cell{
  display:flex;
  flex-direction:column;
  justify-content:center;
  min-width:0;
  min-height:var(--app-list-control-height);
  padding:5px 10px;
  border-left:1px solid #e2e8f0;
  box-sizing:border-box;
}
.app-record-info-cell:first-child{border-left:0;}
.app-record-info-label{
  display:block;
  margin-bottom:2px;
  color:#718096;
  font-size:10px;
  line-height:1.15;
  font-weight:800;
  letter-spacing:-.1px;
}
.app-record-info-value{
  display:block;
  min-width:0;
  color:#334155;
  font-size:13px;
  line-height:1.3;
  font-weight:750;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.app-list-row-actions{
  display:flex;
  align-items:stretch;
  justify-content:flex-end;
  gap:7px;
  flex-wrap:nowrap;
  min-width:0;
  min-height:var(--app-list-control-height);
}
.app-list-row-control{
  box-sizing:border-box !important;
  height:var(--app-list-control-height) !important;
  min-height:var(--app-list-control-height) !important;
  max-height:var(--app-list-control-height) !important;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  white-space:nowrap;
}
select.app-list-row-control{display:block;}

@media(max-width:760px){
  .app-list-row-actions{width:100%;justify-content:flex-start;flex-wrap:wrap;}
}

/* 기존 app-standard-* 이름은 신규 컴포넌트의 alias로만 유지한다. */
.app-standard-list-page{display:flex;flex-direction:column;gap:var(--app-page-gap);width:100%;min-width:0;max-width:none;margin:0;}
.app-standard-page-hero{min-height:86px;}
.app-standard-filter-card{margin:0;}
.app-standard-result-list{display:grid;grid-template-columns:minmax(0,1fr);gap:10px;}

@media(max-width:760px){
  .app-page{gap:11px !important;padding-bottom:28px !important;}
  .app-page-header,
  .app-page-header-card > .app-page-header{
    min-height:0 !important;
    padding:14px !important;
    align-items:flex-start !important;
    flex-direction:column !important;
    gap:11px !important;
  }
  .app-page-header .app-page-title,
  .app-page-header > :first-child > h1,
  .app-page-header > :first-child > h2{
    font-size:19px;
  }
  .app-page-actions{
    width:100%;
    justify-content:flex-start;
  }
}

/* =========================================================
   STRUCTURAL LAYOUT PRIMITIVES
   -------------------------------------------------------------------------
   템플릿의 inline style로 반복하던 비시각적 배치 규칙만 제공한다.
   색상/폰트/세부 간격은 각 공용 component 또는 domain CSS가 소유한다.
   ========================================================= */
.app-scroll-region{overflow:auto;}
.app-inline{display:inline !important;}
.app-prewrap{white-space:pre-wrap;}
.app-text-center{text-align:center;}
.app-grid-full{grid-column:1 / -1 !important;}
.app-stack--xs{gap:6px !important;}
.app-stack--sm{gap:10px !important;}
.app-stack--md{gap:12px !important;}
.app-actions--tight{margin-top:10px !important;}
.app-actions--compact{margin-top:12px !important;}
.app-actions--end{justify-content:flex-end !important;}
.app-mt-sm{margin-top:10px !important;}
.app-filter-row{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}
.app-filter-grow{flex:1 1 260px;min-width:260px;}
.app-control--xs{width:80px !important;}
.app-control--month{width:130px !important;}
.app-control--md{width:150px !important;}
.app-response-actions{margin-top:18px;}
@media(max-width:760px){
  .app-filter-grow{min-width:0;width:100%;}
}
