/* ERP 공통 레이아웃과 UI 요소. 거래처 전용 스타일은 clients.css에서 관리합니다. */

/* 기본 스타일 */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: #263345;
  background: var(--erp-page-bg);
  font:
    14px 'Segoe UI',
    'Malgun Gothic',
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--erp-focus);
  outline-offset: 2px;
}

a {
  text-decoration: none;
}

/* 공통 레이아웃 · 세 열의 상단 높이는 한곳에서 관리 */

.erp-shell {
  display: flex;
  min-height: 100vh;
  --erp-header-height: 60px;
}

.rail-header,
.sidebar-header {
  height: var(--erp-header-height);
  min-height: var(--erp-header-height);
  flex: 0 0 var(--erp-header-height);
  width: 100%;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #e5e7ed;
}

.main {
  margin-left: 272px;
  width: calc(100% - 272px);
}

/* Rail · 업무 아이콘 메뉴 */

.rail {
  width: 61px;
  background: var(--erp-rail-bg);
  border-right: 1px solid var(--erp-rail-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
}

.rail-header {
  justify-content: center;
}

.brand {
  background: var(--erp-brand);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  font-weight: 800;
  font-size: 23px;
  margin-bottom: 18px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.rail-header .brand {
  margin: 0;
}

.rail-links {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  min-height: 0;
}

.rail-links a {
  display: block;
  text-align: center;
  min-height: 58px;
  padding: 4px 0 8px 0;
  font-size: 9px;
  font-weight: 700;
  color: var(--erp-rail-text);
}

.rail-links a span {
  display: block;
  font-size: 21px;
  margin-bottom: 6px;
}

.rail-links a.active {
  background: var(--erp-rail-active-bg);
  color: var(--erp-accent-strong);
  font-weight: 700;
}

.rail .avatar {
  margin-top: auto;
}

.rail > .avatar {
  margin-bottom: 18px;
  flex-shrink: 0;
}

/* Sidebar · 세부 메뉴 */

.sidebar {
  position: fixed;
  inset: 0 auto 0 61px;
  width: 211px;
  background: #fff;
  border-right: 1px solid #e5e7ed;
  padding: 0;
  z-index: 15;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 0 16px;
}

.wordmark {
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 33px;
  font-size: 19px;
}

.wordmark small {
  font-size: 10px;
  letter-spacing: 2px;
  color: #999;
  display: block;
  margin-top: 5px;
}

.sidebar-header .wordmark {
  margin: 0;
  white-space: nowrap;
  font-size: 18px;
}

.sidebar-header .wordmark small {
  font-size: 8px;
  letter-spacing: 0.7px;
  margin-top: 4px;
}

.sidebar-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 16px 24px;
}

.side-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: #a1a6b2;
  margin: 26px 12px 13px;
}

.sidebar h3 {
  font-size: 14px;
  margin: 16px 12px;
}

.side-link {
  display: block;
  padding: 7px 14px;
  margin: 3px 0;
  border-radius: 7px;
  color: #7d8594;
  font-size: 12px;
}

.side-link.active {
  background: var(--erp-active-bg);
  color: var(--erp-brand);
  font-weight: 700;
}

.side-foot {
  border-top: 1px solid #eee;
  margin-top: 50px;
  padding: 20px 10px;
  color: #929aaa;
  font-size: 11px;
  line-height: 1.8;
}

/* 설정 파일의 depth에 따른 세부 메뉴 계층 */
.side-menu .side-link {
  overflow-wrap: anywhere;
  line-height: 1.5;
}
.side-menu .depth-1 {
  font-weight: 600;
}
.side-menu .depth-2 {
  padding-left: 22px;
  font-size: 11px;
}
.side-menu .depth-3 {
  padding-left: 38px;
  font-size: 11px;
}
.side-branch {
  color: #a1a6b2;
  margin-right: 5px;
}
.side-group-title {
  padding: 20px 14px 6px;
  color: #8d95a3;
  font-size: 11px;
  font-weight: 700;
  border-bottom: 1px solid black;
}
.side-group-title.depth-4 {
  /* margin-top: 10px; */
  /* border-top: 1px solid #eef0f5; */
}
.rail-links a {
  overflow-wrap: anywhere;
  line-height: 1.4;
}

/* Topbar · 현재 위치와 사용자 정보 */

.topbar {
  height: var(--erp-header-height);
  background: #fff;
  border-bottom: 1px solid #e5e7ed;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  min-height: var(--erp-header-height);
}

.crumb {
  color: #949ba8;
  font-size: 12px;
}

.crumb strong {
  color: #344054;
  margin-left: 10px;
}

.top-actions {
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 12px;
}

.avatar {
  background: var(--erp-avatar-bg);
  color: var(--erp-brand);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.demo-dot {
  color: var(--erp-accent-muted);
}

.mobile-menu {
  display: none;
}

/* 본문과 페이지 제목 */

.content {
  padding: 32px;
  max-width: 1800px;
  margin: auto;
}

.eyebrow {
  color: var(--erp-eyebrow);
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0;
}

h1 {
  font-size: 25px;
  letter-spacing: -1px;
  margin: 8px 0;
}

p.subtitle {
  color: #929aaa;
  font-size: 12px;
  margin: 0;
}

.footer {
  display: flex;
  justify-content: space-between;
  margin-top: 22px;
  font-size: 10px;
  color: #a5acb8;
}

/* 공통 버튼과 입력 요소 */

.btn {
  padding: 10px 16px;
  border: 1px solid #dfe3eb;
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
}

.btn-primary {
  background: var(--erp-primary);
  border-color: var(--erp-primary);
  color: #fff;
}

.form-control,
.form-select {
  border: 1px solid #dfe3eb;
  border-radius: 6px;
  padding: 9px 11px;
  background: #fff;
  color: #536071;
  font-size: 12px;
}

.search {
  width: 250px;
}

/* 통계 카드와 패널 */

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 25px;
}

.stat {
  background: #fff;
  border: 1px solid #e5e7ed;
  border-radius: 10px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
}

.stat label {
  font-size: 11px;
  color: #8d95a3;
}

.stat strong {
  display: block;
  font-size: 26px;
  margin: 10px 0 6px;
  letter-spacing: -1px;
}

.stat small {
  font-size: 10px;
  color: #9ca3af;
}

.stat .icon {
  background: var(--erp-icon-bg);
  color: var(--erp-accent-text);
  width: 37px;
  height: 37px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 19px;
}

.panel {
  background: #fff;
  border: 1px solid #e3e6ed;
  border-radius: 10px;
  overflow: hidden;
}

/* 목록 · 탭, 검색, 테이블, 페이지 이동 */

.tabs {
  display: flex;
  border-bottom: 1px solid #e9ecf1;
  padding: 0 22px;
  gap: 27px;
}

.tabs button {
  padding: 19px 1px;
  font-size: 12px;
  color: #8d95a3;
  border-bottom: 2px solid transparent;
}

.tabs button.active {
  color: var(--erp-brand);
  border-bottom-color: var(--erp-brand);
  font-weight: 700;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 22px;
  align-items: center;
}

.search-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.count {
  padding: 0 22px 15px;
  font-size: 11px;
  color: #929aaa;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
  font-size: 11px;
}

th {
  background: #f8f9fc;
  color: #9199a6;
  font-weight: 500;
  padding: 14px 15px;
  border-top: 1px solid #edf0f5;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
}

td {
  padding: 18px 15px;
  border-bottom: 1px solid #eef0f5;
  color: #687487;
}

td.company {
  font-weight: 700;
  color: #344054;
}

td small {
  display: block;
  color: #a2aab7;
  font-size: 10px;
  margin-top: 5px;
}

.row-link {
  font-weight: 700;
  text-align: left;
  padding: 0;
  color: #344054;
}

.badge {
  font-size: 10px;
  padding: 5px 9px;
  border-radius: 5px;
  background: #eaf5f0;
  color: #4d9c7e;
}

.badge.wait {
  background: #fff5e5;
  color: #bc9752;
}

.badge.end {
  background: #f0f1f5;
  color: #9298a4;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px;
  color: #9ca3af;
  font-size: 11px;
}

.pages {
  display: flex;
  gap: 6px;
}

.pages button {
  padding: 7px 11px;
  border: 1px solid #eee;
  border-radius: 5px;
}

.empty {
  padding: 50px;
  text-align: center;
  color: #999;
}

/* 상세·입력 화면의 공통 요소 */

.dialog-body {
  padding: 24px;
  max-height: 65vh;
  overflow: auto;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: #687487;
}

.form-grid .wide {
  grid-column: 1/-1;
}

.section-title {
  font-size: 13px;
  margin: 0 0 18px;
  border-left: 3px solid var(--erp-section-accent);
  padding-left: 10px;
}

.dialog-actions {
  padding: 18px 24px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 25px;
}

.detail-grid dt {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 8px;
}

.detail-grid dd {
  font-size: 13px;
  margin: 0;
}

.notice {
  font-size: 11px;
  background: var(--erp-notice-bg);
  color: var(--erp-accent-text);
  padding: 12px;
  border-radius: 6px;
  margin-top: 24px;
}

/* 워크스페이스와 준비 중인 업무 화면 */

.workspace-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.workspace-cards article {
  padding: 24px;
}

.activity {
  padding: 16px 0;
  border-bottom: 1px solid #eee;
  font-size: 12px;
}

.activity small {
  display: block;
  margin-top: 8px;
  color: #999;
}

.module-placeholder {
  padding: 28px;
}

.module-placeholder .btn {
  margin-top: 22px;
}

/* 반응형 · 넓은 화면 → 태블릿 → 모바일 */

@media (min-width: 1600px) {
  td {
    padding: 22px 20px;
  }
}

@media (max-width: 1150px) {
  .sidebar {
    width: 190px;
  }

  .main {
    margin-left: 262px;
    width: calc(100% - 262px);
  }

  .content {
    padding: 24px;
  }

  .stats {
    gap: 10px;
  }

  .stat {
    padding: 15px;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 800px) {
  .sidebar {
    display: none;
  }

  .main {
    margin-left: 72px;
    width: calc(100% - 72px);
  }

  .sidebar.open {
    display: block;
    box-shadow: 20px 0 40px #0002;
  }

  .mobile-menu {
    display: inline;
  }

  .topbar {
    padding: 0 16px;
  }

  .content {
    padding: 20px 14px;
  }

  .stats {
    grid-template-columns: 1fr 1fr;
  }

  .page-heading {
    gap: 12px;
  }

  .top-actions .user-text {
    display: none;
  }

  .search {
    width: 180px;
  }

  .footer {
    line-height: 1.8;
    gap: 15px;
  }

  .workspace-cards {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .rail {
    width: 58px;
  }

  .main {
    margin-left: 58px;
    width: calc(100% - 58px);
  }

  .sidebar {
    left: 58px;
  }

  .page-heading {
    align-items: flex-start;
  }

  h1 {
    font-size: 21px;
  }

  .stat .icon {
    display: none;
  }

  .form-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    gap: 17px;
    padding: 0 15px;
  }

  .toolbar {
    padding: 15px;
  }

  .search {
    width: 100%;
  }

  .top-actions {
    gap: 8px;
  }

  .crumb {
    font-size: 10px;
  }
}

@media (max-width: 480px) {
  .rail-links a {
    width: 46px;
    font-size: 9px;
  }
}

@media (min-width: 801px) and (max-width: 1150px) {
  .sidebar-header .wordmark {
    font-size: 15px;
  }

  .sidebar-header .wordmark small {
    font-size: 7px;
    letter-spacing: 0.3px;
  }
}

/* 상단 색상 테마 선택 */
.theme-picker {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #687487;
  font-size: 11px;
}
.theme-select {
  width: auto;
  min-width: 86px;
  padding: 6px 9px;
  border: 1px solid #dfe3eb;
  border-radius: 6px;
  background: #fff;
  color: var(--erp-accent-strong);
  font: inherit;
}
@media (max-width: 800px) {
  .theme-picker-label {
    display: none;
  }
  .top-actions .demo-dot {
    display: none;
  }
}
@media (max-width: 480px) {
  .theme-select {
    min-width: 72px;
    max-width: 80px;
    padding: 5px;
  }
}
