/* 화면 골격: 데스크톱 상단 메뉴 / 모바일 하단 탭 */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.app-header__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.brand img { width: 50px; height: auto; }
/* 회사 로고: 머리줄이 좁으면(글자 크게) 로고가 줄어들고 알림·내 정보 단추는 그대로 둔다 */
.brand { min-width: 0; }
.brand .brand__logo { flex: 0 1 auto; min-width: 0; height: 36px; width: auto; max-width: 200px; object-fit: contain; object-position: left center; }
.brand:hover { color: var(--text); }

.main-nav { flex: 1; display: flex; flex-wrap: wrap; gap: 0 4px; }
.main-nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: calc(var(--header-h) - 2px);
  padding: 0 12px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  color: var(--text);
  text-decoration: none;
  font-size: 18px;
  font-weight: 500;
}
.main-nav a[aria-current="page"] { font-weight: 700; border-bottom-color: var(--accent); }
.main-nav a:hover { color: var(--accent); }

.header-tools { display: flex; flex-shrink: 0; align-items: center; gap: 8px; }

.app-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 24px;
}
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.split {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-start;
}
.split__main { flex: 999 1 560px; min-width: 0; }
.split__side { flex: 1 1 340px; min-width: 0; }

/* 모듈 안의 보조 메뉴(결재함 목록 등) */
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.subnav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 22px;
  background: var(--surface);
  border: 2px solid var(--line);
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}
.subnav a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
.subnav a[aria-current="page"] .muted { color: inherit; }

.tabbar { display: none; }

.flash {
  max-width: var(--maxw);
  margin: 16px auto 0;
  padding: 0 24px;
}
.flash p {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-weight: 500;
}
.flash .notice { background: var(--ok-soft); color: var(--ok); }
.flash .alert { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 900px) {
  :root { --fs: 17px; --fs-xl: 26px; --fs-lg: 22px; }

  .app-header__inner { min-height: 64px; padding: 0 12px 0 16px; }
  .brand { font-size: 19px; }
  .brand img { width: 44px; }
  .main-nav, .header-tools .hide-mobile { display: none; }
  .header-tools { margin-left: auto; }

  .app-main { padding: 18px 14px calc(var(--tabbar-h) + 28px); }

  .tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface);
    border-top: 2px solid var(--line);
  }
  .tabbar a {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin-top: -2px;
    border-top: 4px solid transparent;
    color: var(--text-2);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
  }
  .tabbar a[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); font-weight: 700; }
  .tabbar .badge { position: absolute; top: 6px; left: 50%; margin-left: 8px; }

  .flash { padding: 0 14px; }
}

@media print {
  .app-header, .tabbar, .page-head__actions, .no-print, .cal-side, .subnav, .flash { display: none !important; }
  .split { display: block; }
  .card { border: 0; box-shadow: none; }
  body { background: #fff; }
  .app-main { padding: 0; max-width: none; }
}

/* 로그인 */
.login { max-width: 440px; margin: 40px auto; }
.login__brand { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 24px; }
.login__rock { width: 150px; height: auto; }
.bell { position: relative; }
.bell .badge { position: absolute; top: 2px; right: -2px; min-width: 22px; height: 22px; font-size: 12px; padding: 0 5px; }

/* 마스터 관리자 (/admin): 회사 화면과 헷갈리지 않게 머리줄 아래에 진한 선 */
.app-header--master { border-bottom: 4px solid var(--text); }
/* 대시보드 회사 목록: PC 는 표, 휴대폰은 회사마다 한 줄 */
.master-rows { display: none; }
/* 휴대폰: 첫 줄은 로고·마스터 표시·단추, 둘째 줄은 옆으로 밀어 보는 메뉴 */
@media (max-width: 900px) {
  .is-master .app-header__inner { flex-wrap: wrap; gap: 0 8px; padding: 8px 12px 0 16px; }
  .is-master .brand { flex: 1 1 auto; min-width: 0; }
  .is-master .main-nav { order: 3; flex: 1 0 100%; display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 0; margin: 4px -12px 0 -16px; padding: 0 8px; }
  .is-master .main-nav a { min-height: 48px; padding: 0 12px; white-space: nowrap; font-size: 17px; }
  .master-rows { display: block; }
}
@media (max-width: 480px) {
  /* 좁은 화면은 글자를 숨기되 화면 읽기 프로그램에는 남긴다 */
  .is-master .brand__text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}

/* 역할별 화면: 네 기둥과 소통 기능 사이 구분선 */
.main-nav__divider { align-self: center; width: 1px; height: 22px; margin: 0 8px; background: var(--line); }
/* 발표 중: 마스터 관리자가 직원으로 들어간 세션 */
.present-bar { position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding: 10px 20px; background: var(--marker); color: var(--text); font-size: 16px; }

/* 앱 2.0 안 '웹 화면'(User-Agent StoneGroupwareApp/2.x): 머리글·하단 탭·뒤로 가기는 앱(Flutter)이 그린다 */
body[data-native-app] .app-header, body[data-native-app] .tabbar { display: none !important; }
body[data-native-app] .app-main { padding-bottom: 28px; }
