/* =========================================================
   TOPBAR (cool)
   ========================================================= */
.topbar{
  position: sticky;
  top: 0;
  z-index: 900;
  padding: 12px 0;
  background: rgba(255,255,255,.74);
  border-bottom: 1px solid var(--hairline);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.topbar-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
}
.icon-btn{
  width: var(--ui-shell-control-height);
  height: var(--ui-shell-control-height);
  border-radius: var(--ui-radius-sm);
  border: 1px solid var(--hairline);
  background: rgba(255,255,255,.80);
  color: var(--text);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  font-size: 18px;
  line-height: 1;
  box-shadow: none;
}
.icon-btn:hover{ background: rgba(255,255,255,.96); border-color: rgba(15,23,42,.10); }
.icon-btn:active{ transform: translateY(1px) scale(.99); }

.topbar-title{ min-width: 0; text-align:center; }
.topbar-title h1{
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.topbar-title .sub{
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}



/* =========================================================
   TOPBAR / DRAWER - migrated final adjustments
   Migrated from the former cross-feature compatibility layer.
   ========================================================= */
/* =========================================================
   HEADER / DRAWER / ESTIMATE ITEM LINK UI 20260716
   ========================================================= */
.topbar-account{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap:9px;
  min-width:0;
}
.topbar-user{
  display:inline-flex;
  align-items:center;
  min-height:var(--ui-control-height-sm);
  max-width:240px;
  padding:0 12px;
  border:1px solid rgba(255,255,255,.34);
  border-radius:var(--ui-radius);
  background:rgba(255,255,255,.14);
  color:#fff;
  font-size:13px;
  font-weight:700;
  line-height:1;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.topbar-logout{white-space:nowrap;}

/* PC·모바일 공통 강력 새로고침 버튼
 * - 회전 상태는 캐시 삭제·페이지 재호출이 진행 중임을 알려준다.
 */
.topbar-refresh{
  display:inline-flex;
  width:38px;
  height:38px;
  flex:0 0 38px;
  color:#1d4ed8;
}
.topbar-refresh > span{
  display:inline-block;
  font-size:24px;
  font-weight:800;
  line-height:1;
  transform-origin:center;
}
.topbar-refresh.is-refreshing{
  cursor:wait;
  opacity:.72;
}
.topbar-refresh.is-refreshing > span{
  animation:topbar-refresh-spin .72s linear infinite;
}
@keyframes topbar-refresh-spin{
  to{transform:rotate(360deg);}
}

.drawer-collapsible{
  display:block;
  padding:0;
}
.drawer-group-summary{
  position:relative;
  display:flex;
  align-items:center;
  min-height:var(--ui-control-height-xs);
  padding:8px 28px 8px 0;
  margin:0;
  cursor:pointer;
  list-style:none;
  user-select:none;
}
.drawer-group-summary::-webkit-details-marker{display:none;}
.drawer-group-summary::after{
  content:"▾";
  position:absolute;
  right:4px;
  top:50%;
  transform:translateY(-50%) rotate(-90deg);
  transition:transform .16s ease;
  color:var(--muted);
  font-size:12px;
}
.drawer-collapsible[open] .drawer-group-summary::after{
  transform:translateY(-50%) rotate(0deg);
}
.drawer-collapsible-body{
  display:grid;
  gap:2px;
  padding-top:6px;
}

@media(max-width:720px){
  /* 모바일에서는 계정명 대신 새로고침·로그아웃 동작을 우선 배치한다. */
  .topbar-row{gap:8px;}
  .topbar-title{flex:1 1 auto;}
  .topbar-user{display:none;}
  .topbar-account{flex:0 0 auto;gap:5px;}
  .topbar-refresh{display:inline-flex;width:38px;height:38px;}
  .topbar-logout{min-width:64px;padding:0 10px;font-size:12px;}
}
@media(max-width:420px){
  /* 폭이 아주 좁은 휴대폰은 부제목만 숨겨 버튼과 제목이 겹치지 않게 한다. */
  .topbar-title .sub{display:none;}
  .topbar-title h1{font-size:16px;}
}
.topbar-user{
  border-color:rgba(37,99,235,.18) !important;
  background:rgba(239,246,255,.92) !important;
  color:#1e3a5f !important;
}
.topbar-logout{
  width:auto !important;
  min-width:72px !important;
  padding:0 13px !important;
  border-radius:var(--ui-radius);
  font-size:13px !important;
  font-weight:700 !important;
}


/* =========================================================
   진행 중 현장입력 복귀
   - PC: 헤더 안의 작은 상태 카드
   - 모바일: 헤더를 가리지 않는 우하단 플로팅 아이콘 + 선택 메뉴
   ========================================================= */
.topbar-field-resume-wrap{
  position:relative;
  display:inline-flex;
  align-items:center;
  min-width:0;
}
.topbar-field-resume{
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-width:0;
  max-width:260px;
  min-height:38px;
  padding:5px 10px;
  border:1px solid rgba(22,101,52,.28);
  border-radius:var(--ui-radius);
  background:#f0fdf4;
  color:#14532d;
  text-decoration:none;
  box-shadow:0 2px 8px rgba(15,23,42,.07);
}
.topbar-field-resume:hover,
.topbar-field-resume:focus-visible{
  border-color:rgba(22,101,52,.5);
  background:#dcfce7;
  color:#14532d;
}
.topbar-field-resume-icon{
  display:grid;
  place-items:center;
  flex:0 0 26px;
  width:26px;
  height:26px;
  border-radius:var(--ui-radius-sm);
  background:#166534;
  color:#fff;
  font-size:16px;
  font-weight:900;
}
.topbar-field-resume-text{
  display:flex;
  flex-direction:column;
  min-width:0;
  line-height:1.15;
}
.topbar-field-resume-text b{font-size:12px;white-space:nowrap;}
.topbar-field-resume-text small{
  max-width:170px;
  margin-top:2px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:10px;
  font-weight:700;
  color:#3f684c;
}
.topbar-field-resume-mobile,
.topbar-field-resume-fab,
.topbar-field-resume-menu{display:none;}

/* 사이드메뉴에서도 기록 삭제 없이 현재 사용자의 복귀 표시만 종료할 수 있다. */
#drawer.drawer .menu-field-resume-reset{
  width:100%;
  min-height:var(--ui-control-height);
  padding:10px 12px;
  border:0;
  border-radius:var(--ui-radius);
  background:transparent;
  color:#64748b;
  text-align:left;
  font:inherit;
  font-size:12px;
  font-weight:700;
  cursor:pointer;
}
#drawer.drawer .menu-field-resume-reset:hover,
#drawer.drawer .menu-field-resume-reset:focus-visible{
  background:#f8fafc;
  color:#b42318;
}

@media(max-width:720px){
  /* 큰 복귀 카드는 모바일 헤더에서 완전히 제거한다. */
  .topbar-field-resume{display:none!important;}
  .topbar-field-resume-wrap{position:static;}
  .topbar-field-resume-mobile{display:block;}

  .topbar-field-resume-fab{
    position:fixed;
    right:14px;
    bottom:calc(78px + env(safe-area-inset-bottom, 0px));
    z-index:19020;
    display:grid;
    place-items:center;
    width:48px;
    height:48px;
    padding:0;
    border:1px solid #166534;
    border-radius:15px;
    background:#166534;
    color:#fff;
    box-shadow:0 8px 20px rgba(15,23,42,.24);
    font-size:23px;
    font-weight:900;
    line-height:1;
    cursor:pointer;
  }
  .topbar-field-resume-fab:hover,
  .topbar-field-resume-fab:focus-visible{
    background:#14532d;
    border-color:#14532d;
  }
  .topbar-field-resume-fab::after{
    content:"현장";
    position:absolute;
    right:-2px;
    bottom:-7px;
    min-width:30px;
    padding:2px 4px;
    border:1px solid #bbf7d0;
    border-radius:var(--ui-radius-xs);
    background:#fff;
    color:#166534;
    font-size:9px;
    font-weight:900;
    line-height:1.1;
    box-shadow:0 2px 6px rgba(15,23,42,.08);
  }

  .topbar-field-resume-menu{
    position:fixed;
    right:12px;
    bottom:calc(140px + env(safe-area-inset-bottom, 0px));
    z-index:19025;
    width:min(290px,calc(100vw - 24px));
    padding:10px;
    border:1px solid #cbd5e1;
    border-radius:var(--ui-radius-lg);
    background:#fff;
    box-shadow:0 14px 34px rgba(15,23,42,.24);
  }
  [data-field-resume-root].is-open .topbar-field-resume-menu{display:grid;gap:8px;}
  .topbar-field-resume-menu-title{
    display:flex;
    flex-direction:column;
    min-width:0;
    padding:2px 2px 4px;
  }
  .topbar-field-resume-menu-title b{font-size:13px;color:#14532d;}
  .topbar-field-resume-menu-title small{
    margin-top:3px;
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
    font-size:11px;
    font-weight:700;
    color:#64748b;
  }
  .topbar-field-resume-menu-go,
  .topbar-field-resume-menu-reset{
    display:flex;
    align-items:center;
    justify-content:center;
    min-height:var(--ui-control-height);
    padding:8px 10px;
    border-radius:var(--ui-radius);
    font:inherit;
    font-size:13px;
    font-weight:800;
    text-decoration:none;
    cursor:pointer;
  }
  .topbar-field-resume-menu-go{
    border:1px solid #166534;
    background:#f0fdf4;
    color:#14532d;
  }
  .topbar-field-resume-menu-reset{
    border:1px solid #cbd5e1;
    background:#fff;
    color:#475569;
  }
  .topbar-field-resume-menu-reset:disabled{opacity:.55;cursor:wait;}
  .topbar-field-resume-menu-help{
    display:block;
    padding:0 2px 2px;
    color:#64748b;
    font-size:10px;
    line-height:1.35;
  }

  /* 실제 visualViewport가 줄어든 경우에만 키보드가 열린 것으로 본다. 단순 focus만으로 버튼을 숨기지 않는다. */
  body.field-resume-keyboard-open .topbar-field-resume-fab,
  body.field-resume-keyboard-open .topbar-field-resume-menu{
    display:none!important;
  }
  /* 사이드메뉴를 연 동안에는 플로팅 버튼이 메뉴 위를 덮지 않는다. */
  body.drawer-lock .topbar-field-resume-fab,
  body.drawer-lock .topbar-field-resume-menu{
    display:none!important;
  }
}

/* Drawer category accordion — top-level categories start collapsed to keep the menu short. */
.drawer-body > .drawer-collapsible{
  margin:4px 0;
  padding:0;
  border:0;
}
.drawer-body > .drawer-collapsible > .drawer-group-summary{
  min-height:var(--ui-control-height);
  margin:0;
  padding:8px 30px 8px 10px;
  border:1px solid transparent;
  border-radius:var(--ui-radius-sm);
  color:#314a66;
  font-size:13px;
  font-weight:800;
}
.drawer-body > .drawer-collapsible > .drawer-group-summary::after{right:10px;}
.drawer-body > .drawer-collapsible[open] > .drawer-group-summary{
  border-color:#d4e1f0;
  background:#f5f9ff;
  color:#174f91;
}
.drawer-body > .drawer-collapsible > .drawer-collapsible-body{
  gap:2px;
  margin:2px 0 7px 10px;
  padding:4px 0 2px 8px;
  border-left:2px solid #dbe7f5;
}
.drawer-body > .drawer-collapsible .menu-link{
  min-height:var(--ui-control-height-sm);
  padding:10px 10px;
}
.drawer-body > .drawer-quick-menu-group{
  border-left:0;
  padding-left:0;
}
@media (hover:hover) and (pointer:fine){
  .drawer-body > .drawer-collapsible > .drawer-group-summary:hover{
    border-color:#d7e3f1;
    background:#f8fbff;
  }
}


/* 2026-08-31 모바일 fixed-control 충돌 방지
 * 목록의 고정 페이징이 있는 화면은 현장복귀 FAB를 작은 보조 액션으로 축소한다.
 * 기능은 유지하되 업무 카드의 상태/버튼을 가리는 면적을 최소화한다.
 */
@media(max-width:720px){
  body.app-modern-ui:has(.app-list-pagination-card) .topbar-field-resume-fab{
    right:8px;
    bottom:calc(72px + env(safe-area-inset-bottom, 0px));
    width:38px;
    height:38px;
    border-radius:11px;
    font-size:19px;
    box-shadow:0 6px 16px rgba(15,23,42,.20);
  }
  body.app-modern-ui:has(.app-list-pagination-card) .topbar-field-resume-fab::after{display:none;}
  body.app-modern-ui:has(.app-list-pagination-card) .topbar-field-resume-menu{
    right:8px;
    bottom:calc(118px + env(safe-area-inset-bottom, 0px));
  }

  /* 업데이트 알림이 떠 있을 때 두 fixed UI가 같은 자리를 점유하지 않는다. */
  body.app-modern-ui:has(.pwa-runtime-notice:not([hidden])) .topbar-field-resume-fab{
    bottom:calc(92px + env(safe-area-inset-bottom, 0px));
  }
  body.app-modern-ui:has(.pwa-runtime-notice:not([hidden])) .topbar-field-resume-menu{
    bottom:calc(140px + env(safe-area-inset-bottom, 0px));
  }
}
