:root {
  --bg: #f6f8fb;
  --chrome-bg: #fbfcff;
  --panel: #ffffff;
  --panel-soft: #f9fbff;
  --muted: #98a2b3;
  --line-strong: rgba(15, 23, 42, 0.16);
  --shell-divider: rgba(15, 23, 42, 0.12);
  --sidebar: 292px;
  --rail: 56px;
  --shell-corner-radius: 18px;
  --sidebar-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sidebar-duration: 0.46s;
}

body {
  display: block;
  min-height: 100svh;
  padding: 0;
  background: var(--chrome-bg);
  overflow-x: hidden;
}

body::before {
  display: none;
}

.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100svh;
  position: relative;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: var(--chrome-bg);
  pointer-events: none;
  transition: width var(--sidebar-duration) var(--sidebar-ease);
  z-index: 0;
}

.app-shell::after {
  /* 제목줄 둥근 모서리(top-left radius) 뒤를 메뉴 배경색으로 고정 채움.
     본문(#fff)이 스크롤로 그 notch에 비쳐 흰 틈처럼 보이는 걸 막는다.
     topbar(z-index 103) 아래, 본문(z-index 25) 위. */
  content: "";
  position: fixed;
  top: 0;
  left: calc(var(--sidebar) - 1px);
  width: var(--shell-corner-radius);
  height: var(--shell-corner-radius);
  background: var(--chrome-bg);
  z-index: 102;
  pointer-events: none;
  transition: left var(--sidebar-duration) var(--sidebar-ease);
}

html.is-sidebar-collapsed .app-shell,
html.sidebar-collapsed-initial .app-shell,
.app-shell.is-sidebar-collapsed,
.app-shell.sidebar-collapsed {
  --sidebar: 72px;
}

.sidebar {
  position: relative;
  align-self: stretch;
  flex: 0 0 var(--sidebar);
  width: var(--sidebar);
  min-height: 100svh;
  background: var(--chrome-bg);
  z-index: 100;
  overflow: visible;
  transition:
    flex-basis var(--sidebar-duration) var(--sidebar-ease),
    width var(--sidebar-duration) var(--sidebar-ease);
}

.sidebar::after {
  content: "";
  position: fixed;
  top: var(--shell-corner-radius);
  bottom: 0;
  left: calc(var(--sidebar) - 1px);
  z-index: 102;
  width: 1px;
  background: var(--shell-divider);
  box-shadow: -1px 0 2px rgba(15, 23, 42, 0.06);
  pointer-events: none;
  transition: left var(--sidebar-duration) var(--sidebar-ease);
}

.rail {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 101;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 72px;
  height: 100svh;
  padding: 12px 8px;
  border-right: 0;
  background: var(--chrome-bg);
  /* 짧은 화면에서도 하단 아이콘까지 스크롤로 도달 (스크롤바는 숨김) */
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  opacity: 0;
  transform: translateX(-10px);
  pointer-events: none;
  transition:
    opacity var(--sidebar-duration) var(--sidebar-ease),
    transform var(--sidebar-duration) var(--sidebar-ease);
}

.rail::-webkit-scrollbar {
  width: 0;
  height: 0;
}

html.is-sidebar-collapsed .rail,
html.sidebar-collapsed-initial .rail,
.app-shell.is-sidebar-collapsed .rail,
.app-shell.sidebar-collapsed .rail {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

html.is-sidebar-collapsed .side-panel,
html.sidebar-collapsed-initial .side-panel,
.app-shell.is-sidebar-collapsed .side-panel,
.app-shell.sidebar-collapsed .side-panel {
  opacity: 0;
  transform: translateX(-14px);
  pointer-events: none;
}

.brand-mark,
.rail-button,
.menu-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.brand-mark {
  border: 1px solid rgba(39, 88, 216, 0.2);
  border-radius: 999px;
  background: #fff;
  color: var(--accent-strong, #163c9f);
  text-decoration: none;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(27, 46, 86, 0.08);
}

.rail-brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rail-button,
.menu-icon {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #475467;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.menu-icon[hidden],
.menu-link[hidden] {
  display: none !important;
}

.menu-icon {
  position: relative;
}

.admin-menu-badge {
  display: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

.admin-menu-badge.is-visible {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.menu-icon .admin-menu-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  font-size: 10px;
  line-height: 16px;
}

.rail-button:hover,
.menu-icon:hover,
.menu-icon.is-active {
  background: #eef3ff;
  color: var(--accent-strong, #163c9f);
}

.rail-button i,
.menu-icon i {
  font-size: 19px;
}

.rail-spacer {
  flex: 1 1 auto;
}

.side-panel {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 101;
  width: 292px;
  height: 100svh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 14px 16px;
  /* 창 높이가 메뉴 전체 높이보다 작아도 하단 메뉴까지 스크롤로 도달 가능 */
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--chrome-bg);
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
  transition:
    opacity var(--sidebar-duration) var(--sidebar-ease),
    transform var(--sidebar-duration) var(--sidebar-ease);
}

.side-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 0;
  min-width: 0;
}

.side-brand-home {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.side-collapse-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #667085;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  margin-left: auto;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.side-collapse-btn:hover {
  background: #eef3ff;
  color: var(--accent-strong, #163c9f);
}

.side-collapse-btn i {
  font-size: 18px;
}

.side-brand-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.side-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  object-fit: cover;
  flex: 0 0 auto;
  display: block;
}

.side-title strong {
  color: #101828;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}

.side-title span {
  color: var(--sub, #5b6474);
  font-size: 12px;
  line-height: 1.35;
}

.side-search {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.side-search-input {
  width: 100%;
  height: 16px;
  min-width: 0;
  min-height: 16px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text, #0f172a);
  font: inherit;
  font-size: 13px;
  line-height: 16px;
  padding: 0;
}

.side-search-input::placeholder {
  color: #98a2b3;
}

.side-search i {
  font-size: 16px;
  flex: 0 0 auto;
}

.menu-group {
  display: grid;
  gap: 3.5px;
}

.menu-stack {
  display: grid;
  gap: 22px;
  /* 짧은 화면에서 그룹 목록만 내부 스크롤 (상단 로고/검색·하단 My Page 고정) */
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.menu-label {
  padding: 0 8px;
  color: #98a2b3;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.menu-stack .menu-group[aria-label="업무 메뉴"]::before {
  content: "Workflows";
  padding: 0 8px;
  color: #98a2b3;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-transform: uppercase;
}

.menu-stack .menu-group[aria-label="업무 메뉴"] > .menu-label {
  display: none;
}

.menu-link {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  color: #344054;
  text-decoration: none;
  font-size: 13px;
  line-height: 1.2;
  transition: background 0.18s ease, color 0.18s ease;
}

.menu-link:hover,
.menu-link.is-active {
  background: #eef3ff;
  color: var(--accent-strong, #163c9f);
}

.menu-link i {
  width: 28px;
  text-align: center;
  color: inherit;
  font-size: 17px;
}

.menu-link > span:not(.admin-menu-badge) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-footer {
  margin-top: auto;
  padding: 18px 8px 4px;
  display: grid;
  gap: 12px;
}

.holiday-notice {
  color: #d92d20;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.guide-topbar,
.company-topbar,
.search-topbar,
.oem-topbar,
.page-topbar,
.request-topbar,
.visit-topbar,
.order-topbar,
.task-topbar,
.item-topbar {
  position: fixed;
  top: 0;
  left: calc(var(--sidebar) - 1px);
  right: 0;
  /* Above the side-panel (z-index 101) so the rounded top-left corner and
     left border are not clipped by the sidebar — keeps the corner seamlessly
     connected to the vertical divider (sidebar::after, z-index 102). */
  z-index: 103;
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-left: 1px solid var(--shell-divider);
  border-top: 1px solid var(--shell-divider);
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
  border-top-left-radius: var(--shell-corner-radius);
  background: #fff;
  box-shadow: none;
  overflow: visible;
  pointer-events: none;
  isolation: isolate;
  transition: left var(--sidebar-duration) var(--sidebar-ease);
}

.guide-topbar::before,
.company-topbar::before,
.search-topbar::before,
.oem-topbar::before,
.page-topbar::before,
.request-topbar::before,
.visit-topbar::before,
.order-topbar::before,
.task-topbar::before,
.item-topbar::before {
  display: none;
}

.guide-topbar-title,
.company-topbar-title,
.search-topbar-title,
.oem-topbar-title,
.page-topbar-title,
.request-topbar-title,
.visit-topbar-title,
.order-topbar-title,
.task-topbar-title,
.item-topbar-title {
  position: relative;
  z-index: 1;
  margin: 0;
  color: #101828;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0;
}

.oem-topbar {
  justify-content: space-between;
  gap: 12px;
  overflow: visible;
  pointer-events: auto;
}

.main-area,
.item-main-area,
.cart-main-area,
.request-main-area,
.visit-main-area {
  position: relative;
  z-index: 25;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 100svh;
  display: block;
  margin-left: -1px;
  padding: 0;
  background: var(--chrome-bg);
}

.main-area::before,
.item-main-area::before,
.cart-main-area::before,
.request-main-area::before,
.visit-main-area::before {
  display: none !important;
}

.main-area::after,
.item-main-area::after,
.cart-main-area::after,
.request-main-area::after,
.visit-main-area::after {
  display: none;
}

.guide-page,
.company-page,
.oem-page,
.content-page,
.order-page,
.visit-page,
.request-stage {
  position: relative;
  width: 100%;
  max-width: none;
  min-height: 100svh;
  margin: 0;
  padding: 56px 20px 20px;
  border-left: 0;
  border-top-left-radius: var(--shell-corner-radius);
  background: #fff;
}

.guide-page::before,
.company-page::before,
.oem-page::before,
.content-page::before,
.order-page::before,
.visit-page::before,
.request-stage::before {
  display: none;
}

@media (max-width: 1200px) {
  :root {
    --sidebar: 72px;
  }

  .rail {
    width: 72px;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }

  .side-panel {
    opacity: 0;
    transform: translateX(-14px);
    pointer-events: none;
  }

  .main-area,
  .item-main-area,
  .request-main-area,
  .visit-main-area {
    padding: 0;
  }
}

@media (max-width: 720px) {
  :root {
    --sidebar: 0px;
  }

  body {
    padding: 0 !important;
  }

  .app-shell {
    display: block;
  }

  .app-shell::before,
  .app-shell::after {
    display: none;
  }

  .sidebar {
    position: fixed;
    inset: auto 0 0;
    flex: 0 0 auto;
    width: 100%;
    height: 62px;
    min-height: 0;
    display: block;
    border-top: 1px solid rgba(15, 23, 42, 0.1);
    border-right: 0;
    overflow: visible;
    z-index: 80;
  }

  .sidebar::after {
    display: none;
  }

  .rail {
    position: static;
    width: 100%;
    height: 62px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 8px;
    padding: 8px 12px;
    border-right: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    background: var(--chrome-bg);
    z-index: 80;
  }

  .rail::-webkit-scrollbar {
    display: none;
  }

  .side-panel {
    display: none;
  }

  .brand-mark,
  .rail-button,
  .rail-spacer {
    display: none;
  }

  .menu-icon {
    scroll-snap-align: center;
  }

  .guide-topbar,
  .company-topbar,
  .search-topbar,
  .oem-topbar,
  .page-topbar,
  .request-topbar,
  .visit-topbar,
  .order-topbar,
  .task-topbar,
  .item-topbar {
    left: 0;
    height: 44px;
    padding: 0 16px;
    border-top: 0;
    border-left: 0;
    border-top-left-radius: 0;
  }

  .main-area,
  .item-main-area,
  .cart-main-area,
  .request-main-area,
  .visit-main-area {
    min-height: calc(100svh - 62px);
    margin-left: 0;
    padding: 0 0 calc(62px + env(safe-area-inset-bottom, 0px));
    z-index: 1;
  }

  .main-area::before,
  .item-main-area::before,
  .cart-main-area::before,
  .request-main-area::before,
  .visit-main-area::before {
    display: none;
  }

  .main-area::after,
  .item-main-area::after,
  .cart-main-area::after,
  .request-main-area::after,
  .visit-main-area::after {
    display: none;
  }

  .guide-page,
  .company-page,
  .oem-page,
  .content-page,
  .order-page,
  .visit-page,
  .request-stage {
    width: 100%;
    min-height: auto;
    padding: 56px clamp(12px, 3.5vw, 16px) calc(clamp(12px, 3.5vw, 16px) + 62px + env(safe-area-inset-bottom, 0px));
    border-left: 0;
    border-top-left-radius: 0;
  }
}

@media (min-width: 721px) {
  .guide-page,
  .company-page,
  .oem-page,
  .content-page,
  .order-page,
  .visit-page,
  .request-stage {
    border-left: 0;
    border-top-left-radius: var(--shell-corner-radius);
    overflow: hidden;
  }
}
