:root {
  color-scheme: light;
  /* 글꼴도 색과 같이 토큰이다 — admin-font.html 에서 바꾸면 app_theme 에
     `--font-family` 로 저장되고, supabase-config.js 가 그걸 :root 에 얹으면서
     필요한 웹폰트 <link> 까지 넣어준다. 여기 적힌 건 **기본값**이다.
     ⚠ system-ui 는 애플 기기에서 San Francisco, 윈도우에서 Segoe UI 다. */
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  font-family: var(--font-family);

  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --surface-hover: #f8fafc;
  --border: #e5e7eb;
  --border-light: #f1f5f9;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-secondary: #374151;
  --text-tertiary: #4b5563;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft-bg: #eff6ff;
  --accent-soft-border: #a5b4fc;
  --selected-bg: #dbeafe;
  --danger: #b91c1c;
  --danger-border: #fecaca;
  --danger-border-hover: #fca5a5;
  --danger-soft-bg: #fef2f2;
  /* 의미색 — 상태를 색으로 알리는 자리. danger 만 있고 나머지가 없어서
     "완료 / 대기중 / 확인함" 같은 걸 구분할 방법이 없었다. */
  --success: #15803d;
  --success-border: #bbf7d0;
  --success-soft-bg: #f0fdf4;
  --warning: #b45309;
  --warning-border: #fde68a;
  --warning-soft-bg: #fffbeb;
  --info: #0369a1;
  --info-border: #bae6fd;
  --info-soft-bg: #f0f9ff;
  --btn-primary-bg: #111827;
  --btn-primary-hover: #1f2937;
  --btn-secondary-bg: #374151;
  --btn-secondary-hover: #4b5563;
  --sidebar-bg: #111827;
  --sidebar-hover: #374151;
  --sidebar-text: #d1d5db;
  --sidebar-text-active: #ffffff;
  /* 한 단 깊어질 때마다 바탕에 얹는 흰색의 양. 색 설정 화면에서 조절한다. */
  --sidebar-depth-tint: 0.02;
  --input-bg: #ffffff;
  --th-bg: #eef2ff;
  --shadow-color: rgba(15, 23, 42, 0.05);
  --shadow-color-strong: rgba(15, 23, 42, 0.2);
  --overlay-bg: rgba(15, 23, 42, 0.4);

  background: var(--bg);
  color: var(--text);
  /* 글꼴 크기 — **자리마다** 다르다. admin-font.html 에서 바꾸면 app_theme 에
     저장되고 모든 화면에 얹힌다(색·글꼴과 같은 자리다).
     여기 적힌 것이 기본값이고, 표에는 **바꾼 것만** 들어간다. */
  --font-size-sm: 0.65rem;         /* 사이드바 · 헤더 · 좁은 표 */
  --font-size-table: 0.82rem;      /* 표 본문 */
  --font-size-table-sm: 0.58rem;   /* 상세표 */
  --font-size-input: 0.62rem;      /* 표 안 입력칸 */
  --font-size-heading: 1rem;       /* 섹션 제목 */
  --font-size-label: 0.8rem;       /* 작은 제목 · 라벨 */
  --font-size-desc: 0.85rem;       /* 설명글 */
  --font-weight-bold: 600;         /* 제목·강조 */

  /* 아이콘. **모양은 여기서 못 바꾼다** — SVG 가 페이지마다 복붙돼 있어서다
     (admin-icons.html 참고). 크기와 굵기만 토큰이다.
     ⚠ stroke-width 는 SVG 속성(`stroke-width="1.5"`)으로도 박혀 있는데,
     CSS 가 표현 속성을 이기므로 이 토큰이 덮는다. */
  /* 어느 아이콘 세트를 쓰나 — icons.js 가 이 값을 보고 고른다.
     admin-icons.html 에서 바꾸면 app_theme 에 저장된다. */
  --icon-set: outline;
  --icon-size: 11px;
  --icon-weight: 1.5;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0d1117;
  --surface: #161b22;
  --surface-alt: #1c232c;
  --surface-hover: #212933;
  --border: #2d3542;
  --border-light: #232a34;
  --border-strong: #3a4252;
  --text: #e6e8eb;
  --text-secondary: #cbd2db;
  --text-tertiary: #b0b8c3;
  --text-muted: #8b95a3;
  --text-faint: #6b7684;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft-bg: #17233b;
  --accent-soft-border: #3b4a7a;
  --selected-bg: #1e3a5f;
  --danger: #f87171;
  --danger-border: #7f1d1d;
  --danger-border-hover: #991b1b;
  --danger-soft-bg: #2a1315;
  --success: #4ade80;
  --success-border: #14532d;
  --success-soft-bg: #10231a;
  --warning: #fbbf24;
  --warning-border: #78350f;
  --warning-soft-bg: #241c0d;
  --info: #38bdf8;
  --info-border: #075985;
  --info-soft-bg: #0b2230;
  --btn-primary-bg: #2563eb;
  --btn-primary-hover: #1d4ed8;
  --btn-secondary-bg: #30363d;
  --btn-secondary-hover: #3d444d;
  --sidebar-bg: #05070a;
  --sidebar-hover: #1c232c;
  --sidebar-text: #9aa4b2;
  --sidebar-text-active: #ffffff;
  --sidebar-depth-tint: 0.02;
  --input-bg: #0d1117;
  --th-bg: #1c2333;
  --shadow-color: rgba(0, 0, 0, 0.35);
  --shadow-color-strong: rgba(0, 0, 0, 0.55);
  --overlay-bg: rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

.app-shell {
  display: grid;
  /* 사이드바가 뿌리 > 그룹 > 메뉴 3~4단 트리가 되면서, 가장 깊은 곳의
     긴 메뉴(프로세스주문받은내역)까지 안 잘리려면 이만큼 필요하다 */
  grid-template-columns: 190px 1fr;
  /* topbar를 없앤 뒤로 행은 하나뿐이다. minmax(0, 1fr)이어야 행이 내용보다
     작아질 수 있다 — 그냥 1fr이면 내용 높이만큼 늘어나 사이드바가 창 밖으로
     삐져나간다. */
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* 좌우 여백을 0으로 두고 각 행이 스스로 들여쓰기를 갖는다 — 그래야
     마우스를 올렸을 때 배경이 사이드바 폭 전체로 깔린다(VS Code 방식) */
  padding: 18px 0;
  min-height: 0;
}

.sidebar-nav,
.sidebar-bottom {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.sidebar-nav {
  overflow-y: auto;
  min-height: 0;
  /* 접기 버튼이 생기면서 사이드바 자식이 셋이 됐다. 이게 남는 자리를
     다 먹어야 메뉴가 위에 붙고 하단이 바닥에 남는다 — 안 그러면
     space-between 이 셋을 벌려서 메뉴가 가운데로 뜬다. */
  flex: 1 1 auto;
}

.sidebar-bottom {
  padding-top: 12px;
  border-top: 1px solid var(--sidebar-hover);
}

/* 행 하나(메뉴 링크 / 그룹 머리) 공통 모양. --depth 단계만큼 왼쪽 여백을
   주는 방식이라, 행 자체는 사이드바 폭을 꽉 채운다 — 그래서 마우스를
   올렸을 때 배경이 폭 전체로 깔린다(VS Code 방식).
   뎁스 안내선(indent guide)은 넣었다가 뺐다 — 없는 편이 더 깔끔했다.
   되살리려면 git 히스토리에서 .sidebar-tick/.sidebar-branch를 찾을 것. */
.sidebar-item,
.sidebar-group-toggle {
  border: none;
  background: none;
  margin: 0;
  font: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  width: 100%;
  height: auto;
  cursor: pointer;
  color: var(--sidebar-text);
  text-align: left;
  white-space: nowrap;
  padding: 3px 6px 3px calc(10px + var(--depth, 0) * 12px);
  /* 한 단 깊어질 때마다 바탕을 조금씩 밝게 — 깊이가 색으로 읽힌다.
     사이드바는 라이트/다크 둘 다 어두우므로 흰색을 얹으면 된다.
     뿌리(depth 0)는 0% 라 사이드바 바탕 그대로다. */
  background-color: rgba(255, 255, 255, calc(var(--depth, 0) * var(--sidebar-depth-tint, 0.02)));
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-item:hover,
.sidebar-group-toggle:hover {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar-item.active {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar-label,
.sidebar-group-label {
  font-size: var(--font-size-sm);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 꺽쇠 — 접혔을 때는 오른쪽(›), 펴졌을 때는 아래를 향한다 */
.sidebar-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 12px;
  opacity: 0.75;
  transition: transform 0.15s ease;
}

.sidebar-group:not(.collapsed) > .sidebar-group-toggle .sidebar-caret {
  transform: rotate(90deg);
}

/* 잎(링크)은 꺽쇠가 없지만 라벨 시작 위치는 그룹과 맞춰야 한다 */
.sidebar-caret-spacer {
  flex: 0 0 12px;
}

/* 사용자 사이드바는 트리만들기의 sidebar 도메인 구조를 그대로 옮긴 것이다.
   맨 위 user_email(로그인 이메일)이 뿌리이고 그 아래가 전부 자식이다. */
.sidebar-group {
  display: flex;
  flex-direction: column;
}

/* 잎 한 줄 = 링크 + 별. 별은 <a> 안에 못 넣어서 겹쳐 놓는다. */
.sidebar-row {
  position: relative;
  display: flex;
}

.sidebar-star {
  position: absolute;
  right: 3px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  padding: 3px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--sidebar-text);
  opacity: 0;
  cursor: pointer;
  transition: opacity 0.12s ease, color 0.12s ease;
}
/* 담아둔 것은 늘 보이고, 나머지는 마우스를 올렸을 때만 나온다 —
   안 그러면 별이 줄마다 늘어서서 메뉴 이름을 읽기 어렵다 */
.sidebar-row:hover .sidebar-star,
.sidebar-star:focus-visible { opacity: 0.5; }
.sidebar-star.on { opacity: 1; color: var(--warning); }
.sidebar-star:hover { opacity: 1; }
.sidebar-star:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* 접었을 때 보이는 짧은 목록 */
.sidebar-marks { display: none; flex-direction: column; }
.sidebar-marks-empty {
  margin: 0;
  padding: 6px 10px;
  font-size: var(--font-size-input);
  line-height: 1.6;
  color: var(--sidebar-text);
  opacity: 0.6;
}

/* 하위 메뉴가 스르르 열리고 닫힌다.
   display:none 은 애니메이션이 안 걸려서, 안쪽을 한 겹 싸고 그 칸의 높이를
   0fr↔1fr 로 바꾼다 — 내용 높이를 미리 몰라도 되는 방법이다. */
.sidebar-group-items {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.18s ease;
}

.sidebar-group-inner {
  display: flex;
  flex-direction: column;
  min-height: 0;      /* 이게 없으면 0fr 이어도 안 줄어든다 */
  overflow: hidden;
}

.sidebar-group.collapsed > .sidebar-group-items {
  grid-template-rows: 0fr;
}

/* 첫 그림과 "동작 줄이기" 설정에서는 애니메이션을 끈다 */
.sidebar-nav.sidebar-no-anim .sidebar-group-items,
.sidebar-nav.sidebar-no-anim .sidebar-caret {
  transition: none;
}

/* ── 사이드바 통째로 접기 ─────────────────────────────────────────────
   메뉴가 글자뿐이라 아이콘만 남길 수가 없다. 얇은 띠로 줄이고 여는
   버튼만 남긴다. */
.sidebar-rail-toggle {
  align-self: flex-start;
  margin: 0 0 8px 10px;
  padding: 5px;
  display: inline-flex;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-text);
  opacity: 0.7;
  cursor: pointer;
  flex: none;
}
.sidebar-rail-toggle:hover {
  background: var(--sidebar-hover);
  opacity: 1;
}
.sidebar-rail-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (min-width: 701px) {
  .app-shell {
    transition: grid-template-columns 0.18s ease;
  }
  /* 접으면 트리 대신 별 단 것만 보인다. 폭은 짧은 이름이 안 잘릴 만큼만. */
  .app-shell.sidebar-collapsed {
    grid-template-columns: 150px 1fr;
  }
  .app-shell.sidebar-collapsed .sidebar-nav {
    display: none;
  }
  .app-shell.sidebar-collapsed .sidebar-marks {
    display: flex;
    /* nav 가 숨으면 이게 남는 자리를 먹어야 목록이 위에 붙는다 —
       안 그러면 space-between 이 가운데로 밀어낸다 */
    flex: 1 1 auto;
  }
}

/* 폰에서는 사이드바가 가로줄이라 접을 게 없다 */
@media (max-width: 700px) {
  .sidebar-rail-toggle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell,
  .sidebar-group-items,
  .sidebar-caret { transition: none; }
}

.main-view {
  padding: 12px 12px 12px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 5px;
}

.header h1 {
  margin: 0;
  font-size: var(--font-size-sm);
}

.header p {
  margin: 8px 0 0;
  color: var(--text-tertiary);
  max-width: 520px;
  font-size: var(--font-size-sm);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(180px, 0.36fr) 14px minmax(260px, 1fr);
  gap: 0;
  flex: 1;
  min-height: 0;
}

/* projectservice.html처럼 트리 두 개 + 목록 패널을 나란히 두는 3열 버전 —
   .workspace와 동일하게 남는 세로 공간을 flex:1로 꽉 채운다 */
.workspace-3col {
  display: grid;
  grid-template-columns: minmax(200px, 0.9fr) minmax(200px, 0.9fr) minmax(220px, 1fr);
  gap: 14px;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1200px) {
  .workspace-3col {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
}

.tree-panel,
.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.panel-resizer {
  position: relative;
  cursor: col-resize;
}

.panel-resizer::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: var(--border);
  border-radius: 1px;
}

.panel-resizer:hover::after,
.panel-resizer.resizing::after {
  background: var(--accent);
}

/* 위아래로 쌓인 두 패널(예: process-order.html의 공정 표/간트차트) 사이에
   쓰는 가로 방향 리사이저 — 기본 .panel-resizer는 좌우 분할용(세로줄,
   col-resize)이라 이쪽은 방향을 뒤집는다 */
.panel-resizer.row-resize {
  cursor: row-resize;
}
.panel-resizer.row-resize::after {
  top: 50%;
  bottom: auto;
  left: 0;
  right: 0;
  width: auto;
  height: 2px;
  transform: translateY(-50%);
}

body.resizing-panels {
  cursor: col-resize;
  user-select: none;
}

.tree-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 2px 0 0;
  flex-wrap: wrap;
  min-height: 32px;
  box-sizing: border-box;
}

.clipboard-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 5px;
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-size: 0.7rem;
}

.clipboard-status button {
  border: none;
  background: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0;
}

.detail-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  height: 32px;
}

/* 트리 위(#createFormPanel — organization/identity/brand의 새 노드 생성/이름
   변경 폼)가 상세표 액션바의 남는 공간에 고정해서, 열고 닫을 때 표가 밀리지
   않게 한다. .tree-actions와 높이를 맞춰서 트리 쪽 툴바랑 표 쪽 툴바가
   나란히 보이게 한다 — 그래서 한 줄로만 표시하고(줄바꿈 없이), 값이 있든
   없든 항상 렌더링된 채로 내용만 비웠다 채운다 */
#createFormPanel,
.create-form-panel { flex: 1 1 auto; display: flex; flex-direction: row; align-items: center; gap: 8px; height: 32px; box-sizing: border-box; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 10px; margin-right: 10px; background: var(--surface-alt); overflow-x: auto; overflow-y: hidden; }
.section-heading { margin: 10px 0 2px; font-size: var(--font-size-label); font-weight: 600; color: var(--text-secondary); }

/* brand.html 전용: Own/Connection은 기존처럼 위아래로 쌓이는 왼쪽 컬럼에
   두고, "제품별 협력사"는 그 오른쪽에 세로로 긴 사이드바처럼 둔다 —
   .main-view의 flex-column 자식이던 걸 이 래퍼 하나로 감싸서, 원래
   위아래로 쓰던 세로 공간 배분(.workspace가 flex:1로 나눠 갖는 것)은
   .brand-layout-main 안에서 그대로 유지된다. */
.brand-layout { display: flex; gap: 16px; flex: 1; min-height: 0; }
.brand-layout-main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
/* 트리:표 비율을 다른 페이지(.workspace 기본값 0.36fr:1fr, 거의 1:3)보다
   좁혀서, 가운데 표가 트리보다 "조금만" 더 넓게 보이게 한다 */
.brand-layout-main .workspace { grid-template-columns: minmax(180px, 0.8fr) 14px minmax(260px, 1fr); }
.brand-layout-sidebar { flex: 0 0 560px; min-width: 0; display: flex; flex-direction: column; min-height: 0; font-size: var(--font-size-sm); }
.brand-layout-sidebar .account-section { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.brand-layout-sidebar .account-table-wrap { overflow-y: auto; }
/* 왼쪽 앱 사이드바(.sidebar-label)와 같은 글씨 크기로 맞춘다 — 제목/표/
   폼 라벨 등 안쪽 요소들이 각자 더 큰 기본 폰트 크기를 갖고 있어서 개별로
   덮어써야 한다 */
.brand-layout-sidebar .section-heading,
.brand-layout-sidebar .account-section-header h3 { font-size: var(--font-size-sm); }
.brand-layout-sidebar .account-table { font-size: var(--font-size-sm); }
.brand-layout-sidebar .account-form label { font-size: var(--font-size-sm); }
.brand-layout-sidebar .table-input { font-size: var(--font-size-sm); }
.brand-layout-sidebar .small-button { font-size: var(--font-size-sm); }
/* order-complete.html의 표 4개도 왼쪽 앱 사이드바(.sidebar-label)와 같은
   글씨 크기로 맞춘다 — .brand-layout-sidebar와 동일한 이유/패턴 */
.order-complete-view .section-heading,
.order-complete-view .account-section-header h3 { font-size: var(--font-size-sm); }
.order-complete-view .account-table { font-size: var(--font-size-sm); }
.order-complete-view .table-input { font-size: var(--font-size-sm); }
.order-complete-view .small-button { font-size: var(--font-size-sm); }

/* 주문완료는 표 넷 + 입출고 맞추기 + 청구서 폼 셋이 세로로 이어져서 한 화면에
   안 들어간다. .main-view 가 overflow:hidden 이라 넘치는 만큼 **그냥 잘렸다**
   — 아래쪽 청구서 폼까지 스크롤로 갈 방법이 없었다. 이 화면만 세로로
   스크롤되게 한다. */
.order-complete-view { overflow-y: auto; }
/* .main-view 는 세로 flex 라 자식들이 기본으로 줄어든다(flex-shrink:1).
   그대로 두면 스크롤이 생기는 대신 표가 납작하게 눌린다. */
.order-complete-view > * { flex: 0 0 auto; }

/* 표마다 높이를 따로 제한한다. 안 하면 완료된 주문이 쌓일수록 첫 표가
   길어져서 아래 표와 청구서 폼이 저 멀리 밀려난다. */
.order-complete-view .account-table-wrap {
  max-height: 300px;
  overflow-y: auto;
}

/* 표 안에서 스크롤하면 머리줄이 위로 사라진다 — 붙여둔다. border-collapse
   에서는 sticky 요소의 테두리가 같이 안 따라오므로 box-shadow 로 그린다. */
.order-complete-view .account-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-alt);
  box-shadow: inset 0 -1px 0 var(--border);
}

.create-form-title { font-weight: 600; font-size: var(--font-size-sm); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; min-width: 0; }
.create-form-body { display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; }
.create-form-fields { display: contents; }
.create-form-fields label { display: flex; flex-direction: row; align-items: center; gap: 4px; font-size: var(--font-size-sm); color: var(--text-secondary); white-space: nowrap; }
.create-form-fields input[type="text"],
.create-form-fields select {
  width: 100px;
}

.search-input {
  flex: 1 1 220px;
  min-width: 220px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 6px 6px;
  font-size: var(--font-size-sm);
  color: var(--text);
  background: var(--surface-alt);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.tree-buttons {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}

.small-button {
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface);
  padding: 3px 14px;
  color: var(--text);
  cursor: pointer;
  font-size: var(--font-size-sm);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

/* 표 안에서 버튼 대신 상태만 알려줄 때 (예: 본인 계정이라 해제 불가) */
.table-hint {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.small-button:hover {
  background: var(--surface-hover);
  border-color: var(--accent-soft-border);
}

.small-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.node-actions {
  display: inline-flex;
  gap: 3px;
  opacity: 1;
  transition: opacity 0.2s ease;
  margin-left: auto;
  flex-shrink: 0;
}

.node-action-btn {
  border: none;
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-secondary);
  width: 16px;
  height: 16px;
  font-size: 0.68rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s ease, transform 0.2s ease;
}

.node-action-btn:hover {
  background: rgba(15, 23, 42, 0.12);
  transform: translateY(0);
}

.node-action-btn.delete {
  color: var(--danger);
}

/* projectservice.html의 "필요"처럼 한 글자 아이콘이 아니라 짧은 텍스트가 들어가는
   버튼용 — 기본 .node-action-btn은 16x16 고정이라 텍스트가 세로로 짜부러진다 */
.node-action-btn.wide {
  width: auto;
  padding: 0 6px;
  white-space: nowrap;
}

/* projectservice.html: 현재 선택된 프로젝트에 이미 "필요"로 담아둔 서비스
   노드의 필요 버튼을 강조 표시 */
.node-action-btn.active {
  background: var(--accent);
  color: #fff;
}

.node-action-btn.active:hover {
  background: var(--accent);
  opacity: 0.9;
}

.requirement-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.requirement-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 0.75rem;
}

.requirement-item-path {
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

.tree-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 24px 60px var(--shadow-color);
  padding: 10px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.tree-root,
.tree-root ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-root li {
  margin: 0;
  padding: 0;
}

.tree-node {
  position: relative;
}

.tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  padding: 1px 4px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  min-width: 0;
  font-size: var(--font-size-sm);
  line-height: 1.15;
  position: relative;
  border-left: 2px solid transparent;
}

.tree-item:hover {
  background: rgba(148, 163, 184, 0.18);
  border-left-color: rgba(59, 130, 246, 0.6);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.08);
}

.tree-item.selected {
  background: var(--selected-bg);
  color: var(--text);
  border-left-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.tree-item-synthetic {
  background: rgba(148, 163, 184, 0.1);
}

.tree-item-synthetic .item-label {
  font-weight: 700;
}

.tree-item .item-label {
  flex: 1;
  min-width: 0;
}

.tree-item-left {
  display: flex;
  align-items: center;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
  justify-content: flex-start;
}

.tree-spacer {
  width: 9px;
  height: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tree-toggle {
  background: transparent;
  border: none;
  width: 9px;
  height: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 3px;
  padding: 0;
  font-size: 0.7rem;
  line-height: 1;
}

.tree-toggle:hover {
  background: rgba(15, 23, 42, 0.08);
}

.icon {
  width: var(--icon-size);
  height: var(--icon-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon svg {
  width: 100%;
  height: 100%;
  /* CSS 가 SVG 표현 속성(stroke-width="1.5")을 이긴다 — 그래서 코드를
     안 고치고도 굵기를 바꿀 수 있다. */
  stroke-width: var(--icon-weight);
}

.tree-node > ul {
  margin-left: 4px;
  border-left: 1px solid var(--border);
  padding-left: 3px;
}

.tree-item.drop-target,
.drop-target > .tree-item {
  outline: 2px dashed #60a5fa;
}

.status-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 8px;
  font-size: 0.72rem;
  color: var(--text-secondary);
}
.status-filter-bar label {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.detail-table tbody tr[draggable="true"] {
  cursor: grab;
}
.detail-table tbody tr.drop-target {
  outline: 2px dashed #60a5fa;
  outline-offset: -2px;
}

.tree-item.cut-pending {
  opacity: 0.5;
}

.item-kind {
  font-size: 0.6rem;
  color: var(--text-muted);
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
  padding: 0 5px;
  margin-left: 4px;
  flex-shrink: 0;
}

.product-workspace {
  display: grid;
  grid-template-columns: minmax(200px, 0.4fr) minmax(320px, 1fr);
  gap: 12px;
  min-height: 0;
}

.product-tree-pane {
  max-height: 460px;
}

.product-table-pane {
  max-height: 460px;
  overflow-y: auto;
}

@media (max-width: 960px) {
  .product-workspace {
    grid-template-columns: 1fr;
  }
}

.detail-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 20px 50px var(--shadow-color);
}

.detail-card {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
}

.detail-card h3 {
  margin: 0;
  font-size: 1.2rem;
}

.detail-body {
  padding: 10px;
  color: var(--text-secondary);
  line-height: 1.7;
  font-size: 0.96rem;
}

.detail-table-wrap {
  margin-top: 0px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
}

.detail-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--font-size-table-sm);
  table-layout: fixed;
}

.detail-table th,
.detail-table td {
  border-bottom: 1px solid var(--border);
  padding: 2px 3px;
  text-align: left;
  vertical-align: middle;
  word-break: break-word;
}

.detail-table th {
  background: var(--th-bg);
  color: var(--text-secondary);
  font-weight: 700;
  letter-spacing: 0.01em;
  position: sticky;
  top: 0;
  z-index: 1;
}

.col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 2;
}

.col-resize-handle:hover,
.col-resize-handle.resizing {
  background: rgba(37, 99, 235, 0.5);
}

body.resizing-columns {
  cursor: col-resize;
  user-select: none;
}

.detail-table tbody tr {
  scroll-margin-top: 22px;
}

.detail-table tbody tr:hover {
  background: rgba(147, 197, 253, 0.1);
}

.detail-table tbody tr.table-row-selected,
.account-table tbody tr.table-row-selected {
  background: var(--selected-bg);
  box-shadow: inset 3px 0 0 var(--accent);
}

.tree-item-selectable {
  cursor: pointer;
}

.detail-table th:nth-child(1),
.detail-table td:nth-child(1),
.detail-table th:nth-child(2),
.detail-table td:nth-child(2) {
  white-space: nowrap;
}

.table-input {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--input-bg);
  border-radius: 4px;
  padding: 2px 4px;
  font-size: var(--font-size-input);
  color: var(--text);
  min-height: 18px;
}

/* process-order.html의 간트차트 표: table-layout:fixed/width:100%인
   .detail-table 기본값 대신, 열 수만큼 표 자체가 넓어지고 그 감싸는
   div(overflow:auto)가 가로 스크롤을 맡는다 */
#ganttTable {
  width: auto;
  table-layout: auto;
}
#ganttTable th,
#ganttTable td {
  white-space: nowrap;
}
.gantt-label-col {
  position: sticky;
  left: 0;
  background: var(--surface-alt);
  min-width: 90px;
  z-index: 2;
}
#ganttTable th.gantt-label-col {
  z-index: 3;
}
.gantt-cell {
  width: 30px;
  min-width: 30px;
  text-align: center;
  cursor: pointer;
}
.gantt-cell:hover {
  background: rgba(37, 99, 235, 0.15);
}
.gantt-cell.gantt-pending-start {
  background: var(--accent);
  color: #fff;
}
.gantt-cell.gantt-in-range {
  background: rgba(37, 99, 235, 0.35);
}

/* process-progress.html의 상태 표시 — 5단계를 동그라미로 늘어놓고, 현재
   단계에만 글씨(라벨)를 붙인다. */
.progress-steps {
  display: flex;
  align-items: center;
  white-space: nowrap;
}
.progress-step {
  display: flex;
  align-items: center;
  gap: 4px;
}
.progress-step-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--border-strong);
  flex-shrink: 0;
}
.progress-step.completed .progress-step-dot {
  background: var(--accent);
}
.progress-step.active .progress-step-dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}
.progress-step-label {
  font-size: var(--font-size-input);
  font-weight: 600;
  color: var(--accent);
}
.progress-step-line {
  width: 12px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 2px;
}
.progress-step-line.completed {
  background: var(--accent);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: var(--surface);
  border-radius: 10px;
  padding: 16px;
  width: 360px;
  max-height: 70vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px var(--shadow-color-strong);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.modal-header h4 {
  margin: 0;
  font-size: var(--font-size-heading);
}

.table-manager-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.table-manager-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: var(--font-size-desc);
}

.table-manager-item .table-manager-actions {
  display: flex;
  gap: 4px;
}

.table-manager-empty {
  color: var(--text-muted);
  font-size: var(--font-size-desc);
}

/* Auth UI */

.table-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Account management page */
.account-page {
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.account-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 20px 50px var(--shadow-color);
}

.account-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.account-section-header h3 {
  margin: 0;
  font-size: var(--font-size-heading);
}

.account-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.account-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-table);
}

.account-table th,
.account-table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
}

.account-table th {
  background: var(--surface-alt);
  color: var(--text-secondary);
  font-weight: 700;
}

.account-table tbody tr:hover {
  background: rgba(147, 197, 253, 0.1);
}

.account-table-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 14px !important;
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: var(--font-size-label);
  color: var(--text-secondary);
}

.account-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

/* process-order.html: 표 위에 주문 전체에 공통으로 붙는 헤더 정보(주문명 등)를
   입력하는 좁은 가로 폼 — 표 안 개별 행 입력칸과 시각적으로 구분되게 카드로 감싼다 */
.order-header-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 8px;
}

.order-header-form label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.68rem;
  color: var(--text-secondary);
}

.order-header-form input {
  width: 110px;
}

.order-header-form .order-header-readonly {
  font-size: 0.72rem;
  color: var(--text);
  min-height: 22px;
  display: flex;
  align-items: center;
}

.small-button.danger {
  color: var(--danger);
  border-color: var(--danger-border);
  margin-right: auto;
}

.small-button.danger:hover {
  background: var(--danger-soft-bg);
  border-color: var(--danger-border-hover);
}

.table-save-btn {
  border: none;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  font-size: 0.6rem;
  cursor: pointer;
  min-height: 18px;
}

.table-save-btn:hover {
  background: var(--accent-hover);
}

.table-empty {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.74rem;
}


/* Settings page */
.settings-page {
  overflow-y: auto;
  min-height: 0;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 20px 50px var(--shadow-color);
  max-width: 480px;
}

.settings-section.wide {
  max-width: 760px;
}

.settings-section .account-section-header {
  gap: 10px;
  flex-wrap: wrap;
}

.settings-section h3 {
  margin: 0 0 4px;
  font-size: var(--font-size-heading);
}

.settings-section-desc {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: var(--font-size-desc);
}

.theme-options {
  display: flex;
  gap: 12px;
}

.theme-option {
  flex: 1;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: var(--surface-alt);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.theme-option:hover {
  border-color: var(--accent-soft-border);
}

.theme-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft-bg);
}

.theme-preview {
  width: 100%;
  height: 48px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: flex;
  overflow: hidden;
}

.theme-preview-sidebar {
  width: 20%;
  height: 100%;
}

.theme-preview.light .theme-preview-sidebar { background: #111827; }
.theme-preview.light .theme-preview-body { background: #ffffff; flex: 1; }
.theme-preview.dark .theme-preview-sidebar { background: #05070a; }
.theme-preview.dark .theme-preview-body { background: #161b22; flex: 1; }

.theme-option-label {
  font-size: var(--font-size-desc);
  color: var(--text-secondary);
  font-weight: 600;
}

@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .panel-resizer {
    display: none;
  }
  /* stacked single-column layout reads better as one scrolling page than
     two cramped independently-scrolling panes */
  .app-shell {
    height: auto;
    min-height: 100vh;
  }
  .main-view {
    overflow: visible;
  }
  .tree-container,
  .detail-card {
    flex: none;
    overflow-y: visible;
    overflow-x: visible;
  }
  /* settings.html's tree sections stack inside an already-scrolling page
     (no split-pane layout to defer to), so keep their own scrollbar here
     instead of inheriting the visible/visible override above — otherwise
     overflowing rows paint outside the box and overlap the next section */
  .settings-page .tree-container {
    overflow-y: auto;
    overflow-x: auto;
  }
}

@media (max-width: 700px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    overflow-x: auto;
  }
  .sidebar-nav,
  .sidebar-bottom {
    flex-direction: row;
  }
  .sidebar-bottom {
    padding-top: 0;
    padding-left: 12px;
    border-top: none;
    border-left: 1px solid var(--sidebar-hover);
  }
  .sidebar-item {
    width: auto;
    height: auto;
    padding: 6px 8px;
  }
}

/* Dashboard page */
.dashboard-summary {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.dashboard-summary-item {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
  box-shadow: 0 20px 50px var(--shadow-color);
}

.dashboard-summary-count {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.dashboard-summary-label {
  font-size: var(--font-size-label);
  color: var(--text-muted);
  margin-top: 2px;
}

.dashboard-page {
  overflow-y: auto;
  min-height: 0;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.dashboard-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 20px 50px var(--shadow-color);
  font-size: var(--font-size-desc);
  color: inherit;
  text-decoration: none;
}

.dashboard-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.dashboard-card-header h4 {
  margin: 0;
  font-size: var(--font-size-heading);
}

.dday-badge {
  background: var(--danger-soft-bg);
  color: var(--danger);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.dashboard-card-overview {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
  color: var(--text-secondary);
}

.dashboard-field-label {
  color: var(--text-muted);
  margin-right: 6px;
}

.progress-bar {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}

.progress-bar-segment {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
}

.progress-bar-segment.filled {
  background: var(--accent);
}

.progress-bar-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.dashboard-icons {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  font-size: var(--font-size-label);
  color: var(--text-secondary);
}

.dashboard-icon.alert {
  color: var(--danger);
}

.dashboard-icon.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.catalog-tree-container {
  max-height: 360px;
}

/* Calendar page */
.calendar-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.calendar-toolbar h3 {
  margin: 0;
  min-width: 110px;
  text-align: center;
}

.calendar-legend {
  display: flex;
  gap: 14px;
  margin-bottom: 12px;
  font-size: var(--font-size-label);
  color: var(--text-tertiary);
}

.cal-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cal-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
}

.cal-dot.intake { background: #2563eb; }
.cal-dot.purchase { background: #f97316; }
.cal-dot.outbound { background: #8b5cf6; }
.cal-dot.inbound { background: #14b8a6; }
.cal-dot.document { background: #64748b; }
.cal-dot.schedule { background: #e11d48; }   /* 사람이 직접 잡은 약속 — 눈에 띄어야 한다 */
.cal-dot.payment { background: #16a34a; }    /* 입출금 예정 — 돈은 문서(회색)와 구분되어야 한다 */

.cal-more {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.calendar-page {
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 20px 50px var(--shadow-color);
}

.calendar-weekday {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
  padding-bottom: 4px;
}

.calendar-day {
  min-height: 68px;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 4px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.calendar-day.other-month {
  border-color: transparent;
  cursor: default;
}

.calendar-day:not(.other-month):hover {
  background: var(--surface-hover);
}

.calendar-day.today {
  border-color: var(--accent);
}

.calendar-day.selected {
  background: var(--selected-bg);
  border-color: var(--accent);
}

.calendar-day-number {
  font-size: var(--font-size-label);
  font-weight: 600;
  color: var(--text-secondary);
}

.calendar-day-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}

.calendar-day-detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 20px 50px var(--shadow-color);
}

.calendar-day-detail h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.calendar-event-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.calendar-event-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: var(--font-size-desc);
  color: var(--text);
  text-decoration: none;
}

.calendar-event-item:hover {
  background: var(--surface-hover);
}

/* 실제로 오간 돈 한 줄 (입출금의 "실제 입출금" 칸).
   분할입금이면 여러 줄이 붙으므로 칸 안에서 접히게 둔다. */
.pay-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.pay-record {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border: 1px solid var(--success-border);
  border-radius: 999px;
  background: var(--success-soft-bg);
  color: var(--success);
  font-size: 12px;
  white-space: nowrap;
}

/* 차액 — **돈이 오간 줄이 아니다.** 받은 돈(초록)과 같은 색으로 그리면
   화면이 "받았다"고 거짓말을 한다. */
.pay-record.writeoff {
  border-color: var(--border-strong);
  background: var(--surface-alt);
  color: var(--text-muted);
}

/* 지우기 ✕ — 조각 안에 얹히므로 테두리도 바탕도 없다. */
.pay-del {
  border: 0;
  background: none;
  padding: 0;
  color: inherit;
  opacity: 0.55;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
}
.pay-del:hover { opacity: 1; }

.pay-add {
  padding: 1px 8px;
  font-size: 12px;
}

/* 상태 한 조각. 표에서 "완료 / 대기중" 같은 걸 글자만이 아니라 색으로도
   알리는 자리다. 색은 의미색 토큰에서 오므로 다크에서도 그대로 맞는다. */
.status-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
}
.status-chip.success { color: var(--success); border-color: var(--success-border); background: var(--success-soft-bg); }
.status-chip.warning { color: var(--warning); border-color: var(--warning-border); background: var(--warning-soft-bg); }
.status-chip.info    { color: var(--info);    border-color: var(--info-border);    background: var(--info-soft-bg); }
.status-chip.danger  { color: var(--danger);  border-color: var(--danger-border);  background: var(--danger-soft-bg); }

/* admin-theme.html 의 "지금 이렇게 보입니다" 칸 */
.theme-sample {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
}
.theme-sample-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

/* ── 말로 설정하기 (dashboard) ────────────────────────────────────────────
   대화는 오래 남기지 않는다 — 설정이 끝나면 이 칸 자체가 사라진다. 그래서
   저장하지 않고 화면에만 둔다. */
.ai-log {
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.ai-log:empty { display: none; }

.ai-turn {
  padding: 8px 11px;
  border-radius: 10px;
  margin-bottom: 6px;
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 0.92rem;
}

.ai-turn.me {
  background: var(--info-soft-bg);
  border: 1px solid var(--info-border);
  margin-left: 15%;
}

.ai-turn.bot {
  background: var(--surface);
  border: 1px solid var(--border);
  margin-right: 15%;
}

.ai-turn.pending { opacity: .6; }

.ai-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.ai-input-row textarea {
  flex: 1;
  resize: vertical;
  font-family: inherit;
}

/* 제안 미리보기 — import 화면과 같은 표 모양을 쓴다 */
.ai-proposal {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface);
}

.ai-proposal h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.ai-proposal-group {
  margin-bottom: 10px;
}

.ai-proposal-group > strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.88rem;
}

.ai-proposal-group ul {
  margin: 0;
  padding-left: 18px;
}

.ai-proposal-group li {
  font-size: 0.88rem;
  line-height: 1.6;
}

/* partner.html 오른쪽 판 안에서 서비스·프로젝트 카테고리를 나란히 둔다.
   좁아지면(오른쪽 판을 줄이거나 작은 화면) 한 줄로 접힌다 — 트리 두 개를
   180px 씩 나눠 가지면 글자가 다 잘린다. */
.partner-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

/* 화면 폭이 아니라 **오른쪽 판의 폭**으로 정해야 한다. 왼쪽 표를 넓게 끌면
   화면이 넓어도 오른쪽은 좁아지기 때문이다. 실제로 1280px 화면에서 오른쪽이
   320px 였고 트리 둘이 220px 씩으로 눌렸다.
   (컨테이너 쿼리를 모르는 브라우저를 위해 화면 폭 규칙도 남겨둔다.) */
@media (max-width: 1100px) {
  .partner-two-col { grid-template-columns: 1fr; }
}

/* 한 줄이 [이름][붙은 회사 칩][+공급][+수요] 라 400px 밑에서는 칩이 접힌다.
   그래서 판이 900px 은 돼야 나란히 둔다 — 대부분의 화면에서는 위아래다. */
@container (max-width: 900px) {
  .partner-two-col {
    grid-template-columns: 1fr;
    /* 프로젝트 카테고리는 열두 줄뿐이라 서비스 쪽에 더 준다 */
    grid-template-rows: 1.7fr 1fr;
  }
}

/* partner.html 은 왼쪽이 트리가 아니라 아홉 칸짜리 표라, 다른 화면의 기본
   비율(0.36fr)로는 표가 반쯤 잘린 채 시작한다. 표 너비(740px)에 맞춰 연다.

   ⚠ 반드시 min-width 미디어쿼리 안에 둔다. 밖에 두면 id 선택자가 더 세서
   좁은 화면에서 한 줄로 접는 규칙(.workspace{1fr})을 이겨버린다. */
@media (min-width: 961px) {
  #partnerWorkspace {
    grid-template-columns: minmax(280px, 760px) 14px minmax(320px, 1fr);
  }
  /* 위 @container 가 이 판의 폭을 잴 수 있게 한다 */
  #partnerWorkspace .detail-panel { container-type: inline-size; }

  /* sourcing.html 은 왼쪽이 트리라 좁아도 되고, 오른쪽 거래처 표가 넓어야 한다 */
  #sourcingWorkspace {
    grid-template-columns: minmax(280px, 0.45fr) 14px minmax(320px, 1fr);
  }
}

/* partner.html 의 머리 막대.
   ⚠ .detail-actions / .tree-actions 를 쓰면 안 된다 — 저것들은 트리 툴바와
   높이를 맞추려고 height:32px 로 고정돼 있어서, 좁아져서 줄바꿈이 나면
   내용이 아래 글과 **겹친다**(오른쪽 판 320px 에서 실제로 겹쳤다). */
/* 줄 하나에 버튼·설명을 늘어놓는 자리. `.detail-actions`/`.tree-actions` 는
   height 가 32px 로 **고정**이라 좁아져서 줄바꿈이 나면 넘친 줄이 아래 글
   위에 겹쳐 찍힌다 — 이건 min-height 라 늘어난다.
   (예전 이름은 .partner-bar 였는데 네 화면이 쓰게 돼서 바꿨다.) */
.action-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

/* ---------------------------------------------------------------------------
   트리는 "고를 것"이고 표가 주인공인 화면 — order-history · receive-history ·
   receive. 이 셋은 .workspace 안에 **트리 판 하나만** 넣는다.

   ⚠ 두 가지가 겹쳐서 화면이 깨져 있었다(2026-08-31 에 고쳤다).

   ① .workspace 는 [트리][손잡이][상세] **3열 그리드**다. 트리만 넣으면
      오른쪽 두 칸이 **빈 채로 자리를 먹는다** — 트리와 표 사이가 허옇게
      비어 보인 이유다. 자식이 트리 하나뿐이면 한 칸으로 둔다.

   ② aside 에 인라인으로 `flex: 1 1 auto` 가 박혀 있었다. basis 가 auto 라
      **표 내용이 넓을수록 표 판이 커진다.** receive.html 은 표가 둘에 칸이
      16개라 표 판이 1210px 까지 자라 **트리 판을 0px 로 밀어냈다** — 트리가
      통째로 사라졌다. basis 를 0 으로 두면 내용 크기와 무관해진다.
   --------------------------------------------------------------------------- */
.workspace:not(:has(.detail-panel)) {
  grid-template-columns: 1fr;
}

/* 트리에는 고르는 데 필요한 만큼만 주고 나머지를 표에 준다. 좁아지면 트리가
   먼저 줄어든다(0 1 …) — 표는 칸이 많아서 더 못 줄인다. */
.brand-layout-main-narrow { flex: 0 1 360px; }
.brand-layout-main-narrow + .brand-layout-sidebar { flex: 1 1 0; min-width: 0; }

/* 진행 중인 건 띠 (dashboard.html).
   작업전/작업중/작업후를 바탕색으로 나눈다 — 사장님이 그린 그림과 같은 구분이다. */
.job-strip th, .job-strip td { white-space: nowrap; }
.job-band { text-align: center; font-weight: 600; }
.job-band-before { background: var(--surface-muted, rgba(128,128,128,.06)); }
.job-band-doing  { background: rgba(214, 178, 46, .10); }
.job-band-after  { background: rgba(56, 132, 214, .10); }
.job-cell { font-size: var(--font-size-heading); line-height: 1; }
.job-done { color: var(--success); }
.job-doing { color: var(--warning); }
.job-todo { color: var(--muted, #9aa0a6); }
.job-past { color: var(--muted, #9aa0a6); opacity: .55; }
.job-skip { color: var(--border); }

/* 글꼴 고르기 (admin-font.html). 색 화면과 달리 **읽어봐야** 고를 수 있어서
   카드마다 그 글꼴로 쓴 견본을 같이 보여준다. */
.font-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.font-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
}
.font-card:hover { border-color: var(--accent, #3b82f6); }
.font-card.selected {
  border-color: var(--accent, #3b82f6);
  box-shadow: inset 0 0 0 1px var(--accent, #3b82f6);
}
.font-card-name { font-size: var(--font-size-label); color: var(--muted, #6b7280); }
.font-card-sample { font-size: var(--font-size-heading); line-height: 1.5; }

/* 아이콘 목록 (admin-icons.html). */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.icon-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: inherit;
  cursor: pointer;
}
.icon-card:hover { border-color: var(--accent, #3b82f6); }
.icon-card-art { display: flex; align-items: center; justify-content: center; min-height: 40px; }
.icon-card-count { font-size: 0.7rem; color: var(--muted, #6b7280); }
/* 로고처럼 가로로 긴 것은 두 칸을 쓴다 — 정사각 상자에서는 안 보인다 */
.icon-card-wide { grid-column: span 3; }
.icon-card-wide .icon-card-art { width: 100%; }
.icon-code {
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 0.72rem;
  line-height: 1.5;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  max-height: 240px;
  overflow: auto;
}

/* 크기·굵기 조절 줄 (admin-font.html · admin-icons.html). */
.size-list { display: flex; flex-direction: column; gap: 6px; }
.size-row {
  display: grid;
  grid-template-columns: minmax(120px, 200px) 1fr 64px;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
}
.size-row-label { font-size: var(--font-size-desc); }
.size-row-value { font-size: var(--font-size-sm); color: var(--muted, #6b7280); text-align: right; }
/* 바꾼 줄은 표시해준다 — 무엇이 기본값이 아닌지 한눈에 */
.size-row.changed .size-row-label::after {
  content: ' •';
  color: var(--accent, #3b82f6);
}
@media (max-width: 640px) {
  .size-row { grid-template-columns: 1fr; gap: 2px; }
  .size-row-value { text-align: left; }
}

/* 아이콘 세트 카드 (admin-icons.html) — 견본은 실제보다 크게 보여준다.
   11px 로는 외곽선과 채움을 구분할 수 없다. */
.icon-set-sample { display: flex; gap: 12px; align-items: center; }
.icon-set-demo { width: 26px; height: 26px; }

/* 지난 발주에서 본뜬 값 (process-order.html).
   ⚠ **숫자가 이미 적힌 채로 뜨는 게 위험한 자리다** — 지난번 수량을 못 보고
   그대로 발주하면 사고다. 그래서 본뜬 칸은 표시가 남고, 고치면 지워진다. */
.table-input.cloned {
  background: var(--warning-soft-bg, rgba(214, 178, 46, .14));
  border-color: var(--warning-border, rgba(214, 178, 46, .5));
}

/* ---------------------------------------------------------------------------
   프로젝트 — 왼쪽 목록 · 오른쪽 작업판. 일을 먼저 만들고 주문이 거기 붙는다.
   --------------------------------------------------------------------------- */
.project-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.project-list-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  overflow-y: auto;
}

/* ⚠ `.search-input` 은 `flex: 1 1 220px` 이다 — 가로 도구줄에서 늘어나라고
   준 값인데, 세로로 쌓은 이 판에서는 **높이가 1383px 로 늘어나** 목록을
   화면 밖으로 밀어냈다. 세로 흐름에서는 안 늘어나게 못박는다. */
.project-list-panel .search-input { flex: 0 0 auto; }

.project-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 0;
  overflow-y: auto;
}

.project-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font-size: var(--font-size-sm);
}
.project-list-item:hover { background: var(--surface-hover); }
.project-list-item.selected {
  background: var(--selected-bg);
  box-shadow: inset 3px 0 0 var(--accent);
}
.project-list-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 오른쪽 판. min-width:0 이 없으면 표가 든 칸이 못 줄어들어 목록을 밀어낸다. */
.project-main { min-width: 0; overflow-y: auto; }

/* 매출 · 매입 · 사양 — 좁아지면 아래로 접힌다(화면 폭이 아니라 판 폭 기준). */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.project-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.project-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 120px;
}
.project-box-title { font-size: var(--font-size-label); font-weight: var(--font-weight-bold); }
.project-box-count { margin: 6px 0; color: var(--text-muted); font-size: var(--font-size-sm); }
.project-box-list { margin: 0; padding-left: 16px; font-size: var(--font-size-sm); }

.project-create { margin-top: 16px; }

/* project.html 의 진행 띠 — process-progress 의 동그라미 띠와 같은 모양인데,
   표 칸이 아니라 머리에 놓이므로 **모든 칸에 이름과 날짜를 붙인다.**
   (저기는 자리가 좁아 현재 칸에만 글씨를 붙인다.) */
.project-flow {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 2px 0;
  margin: 12px 0 4px;
}
.project-flow .progress-step {
  align-items: flex-start;
  gap: 6px;
}
.project-flow .progress-step-dot {
  margin-top: 4px;
}
/* 지나왔는데 기록이 없는 칸 — 아직 안 한 것과 구분한다. */
.project-flow .progress-step.skipped .progress-step-dot {
  background: var(--border-strong);
  box-shadow: 0 0 0 2px var(--surface-2);
}
.project-flow-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.project-flow-label {
  font-size: var(--font-size-input);
  color: var(--text-muted);
}
.project-flow .progress-step.completed .project-flow-label,
.project-flow .progress-step.active .project-flow-label {
  color: var(--text);
  font-weight: 600;
}
.project-flow .progress-step.active .project-flow-label {
  color: var(--accent);
}
.project-flow-date {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  white-space: nowrap;
}
.project-flow .progress-step-line {
  margin: 8px 8px 0;
  width: 28px;
}

/* 목록 칸의 띠 — 동그라미만. 이름 아래 한 줄로 들어가야 해서 글씨를 뺀다.
   무슨 칸인지는 마우스를 올리면 title 로 나온다. */
.project-flow.compact {
  margin: 4px 0 0;
  gap: 0;
}
.project-flow.compact .progress-step-dot {
  width: 7px;
  height: 7px;
  margin-top: 0;
}
.project-flow.compact .progress-step-line {
  width: 10px;
  margin: 0 3px;
}
.project-flow.compact .progress-step.active .progress-step-dot {
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

/* 만드는 길 — 칸이 공정 수만큼 늘어나므로 좁을 때 줄바꿈되게 둔다. */
.project-flow.pipeline {
  margin: 8px 0 0;
}
.project-flow.pipeline .progress-step-line {
  width: 20px;
  margin: 8px 5px 0;
}

/* 프로젝트로 돌아오는 길 — 주문·문서 화면 맨 위.
   [project-return.js](project-return.js) 가 그린다. 떠 있는 조각(floating)이
   아니라 **글의 흐름 안에** 둔다 — 떠 있으면 아래 내용을 가린다. */
.project-return {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border: 1px solid var(--accent-soft-border);
  border-radius: 6px;
  background: var(--accent-soft-bg);
}
.project-return a {
  color: var(--accent);
  font-size: var(--font-size-sm);
  text-decoration: none;
}
.project-return a:hover {
  text-decoration: underline;
}

/* 종이 계산 — 값이 붙은 첫 후보(많이 앉는 순). 답이 아니라 눈에 띄게만. */
.highlight-row td {
  background: var(--accent-soft-bg);
}

/* 앉히기 — 왼쪽 표, 오른쪽 그림. 좁으면 세로로. */
.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 560px);
  gap: 16px;
  align-items: start;
}
@media (max-width: 1100px) {
  .layout-grid { grid-template-columns: minmax(0, 1fr); }
}
.layout-figure svg {
  border-radius: 4px;
}
