/* ============================================================
   O2U AI Hub
   코앤코 디자인시스템 (cnc_design.md) 토큰 적용판 — wm/dm의 style.css와 동일 토큰·컴포넌트를
   그대로 재사용한다 (로그인 LoginPage 패턴, Sidebar 212px, Card/Field/Btn 등).
   ============================================================ */
@import url("https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=block");
@font-face {
  font-family: "SUIT";
  src: url("https://cdn.jsdelivr.net/gh/sunn-us/SUIT/fonts/variable/woff2/SUIT-Variable.woff2")
    format("woff2-variations");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
.msym {
  font-family: "Material Symbols Outlined";
  font-size: 19px;
  line-height: 1;
  vertical-align: -4px;
  font-weight: normal;
  font-style: normal;
  display: inline-block;
}

:root {
  /* primary (브랜드 블루) */
  --p50: #eef4fc; --p100: #d7e6f7; --p200: #b0cdef; --p300: #85b1e5;
  --p400: #5c96da; --p500: #3d78c4; --p600: #2f5fa0; --p700: #274c81;
  --p800: #203d68; --p900: #1a3153;

  /* black alpha (텍스트/보더 위계) */
  --ba4: rgba(0,0,0,.04); --ba10: rgba(0,0,0,.1); --ba20: rgba(0,0,0,.2);
  --ba40: rgba(0,0,0,.4); --ba80: rgba(0,0,0,.8); --ba100: #1c1c1c;

  /* surface */
  --surf: #ffffff; --surf-muted: #f9f9fa;

  /* semantic */
  --success-50: #eafbf1; --success-500: #16a34a; --success-600: #15803d;
  --warning-50: #fef6e7; --warning-500: #f59e0b; --warning-600: #b45309;
  --danger-50: #fdedec;  --danger-500: #dc2626;  --danger-600: #b91c1c;
  --info-50: #eaf6fd;    --info-500: #0ea5e9;    --info-600: #0284c7;

  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 4px 12px rgba(15,23,42,.08);
  --shadow-lg: 0 12px 24px rgba(15,23,42,.10);
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-full: 9999px;

  --font: "SUIT", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;

  /* 하위 호환 (기존 코드가 참조하던 변수명) */
  --ci: var(--p600); --ci-deep: var(--p700);
  --ink: var(--ba100); --muted: var(--ba40); --line: var(--ba10);
  --bg: var(--surf-muted); --card: var(--surf);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ci); text-decoration: none; }

/* ---------- 로그인 (LoginPage 패턴: 좌측 브랜드 패널 + 우측 폼, wm/dm과 동일) ---------- */
.login-wrap {
  min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 44%) 1fr;
  background: var(--surf-muted);
}
.lp-panel {
  background: linear-gradient(160deg, var(--p700), var(--p400));
  color: #fff; padding: 56px 48px; display: flex; flex-direction: column;
  position: relative; overflow: hidden;
}
.lp-panel::after {
  content: ""; position: absolute; right: -90px; bottom: -90px; width: 320px; height: 320px;
  border-radius: 50%; background: rgba(255,255,255,.06);
}
.lp-panel::before {
  content: ""; position: absolute; right: 40px; bottom: 60px; width: 160px; height: 160px;
  border-radius: 50%; background: rgba(255,255,255,.05);
}
.lp-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 44px; }
.lp-logo img { width: 34px; height: 34px; border-radius: 8px; background: var(--surf); padding: 3px; object-fit: contain; }
.lp-logo .co { font-size: 13px; font-weight: 600; color: rgba(255,255,255,.85); letter-spacing: .4px; }
.lp-brand { font-family: Georgia, "Times New Roman", serif; font-size: 44px; font-weight: 700; line-height: 1.1; letter-spacing: 1px; }
.lp-brand b { font-style: italic; color: #bfe0ff; font-weight: 700; margin-right: 4px; }
.lp-sub { font-family: Georgia, "Times New Roman", serif; font-size: 14px; color: rgba(255,255,255,.82); letter-spacing: 3px; text-transform: uppercase; margin-top: 8px; }
.lp-desc { font-size: 13.5px; color: rgba(255,255,255,.75); margin-top: 22px; max-width: 320px; line-height: 1.7; }
.lp-tags { display: flex; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
.lp-tags span { font-size: 11px; font-weight: 600; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.2);
  padding: 5px 11px; border-radius: var(--r-full); color: rgba(255,255,255,.9); }
.lp-foot { margin-top: auto; font-size: 11.5px; color: rgba(255,255,255,.55); letter-spacing: 1.5px; position: relative; z-index: 1; }

.lp-env { margin-top: 26px; padding: 14px 16px; max-width: 320px; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.18); border-radius: var(--r-lg); position: relative; z-index: 1; }
.lp-env-title { font-size: 12px; font-weight: 700; color: rgba(255,255,255,.85); margin-bottom: 10px; }
.lp-env-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }
.lp-env-row label { font-size: 12px; color: rgba(255,255,255,.7); flex: none; }
.lp-env-row select { flex: 1; min-width: 0; font-size: 12px; padding: 5px 8px; border-radius: 6px;
  border: 1px solid rgba(255,255,255,.25); background: rgba(255,255,255,.12); color: #fff; }
.lp-env-row select option { color: #111; }
.lp-env-msg { font-size: 11px; color: rgba(255,255,255,.7); margin-top: 8px; min-height: 14px; }

.lp-modules-list { display: flex; flex-direction: column; gap: 6px; }
.lp-module-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: rgba(255,255,255,.85); }
.lp-module-row input[type="checkbox"] { accent-color: #bfe0ff; width: 14px; height: 14px; flex: none; }
.lp-module-row .msym { font-size: 15px; color: rgba(255,255,255,.6); flex: none; }
.lp-module-row .lp-module-name { flex: 1; }

.lp-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-card {
  background: var(--surf); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 34px 36px; width: 100%; max-width: 400px;
  box-shadow: var(--shadow-md);
}
.login-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; color: var(--ba100); }
.login-card .fs { font-size: 12.5px; color: var(--ba40); margin-bottom: 26px; }
.login-card .field { margin-bottom: 16px; }
.login-card .note { margin: 0 0 18px; }
.login-card #reset-countdown { display: block; margin: -6px 0 12px; }
.lp-link { margin-top: 14px; text-align: center; font-size: 12.5px; }
.lp-link a { color: var(--ba40); text-decoration: none; }
.lp-link a:hover { color: var(--ba100); text-decoration: underline; }

@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .lp-panel { display: none; }
}

/* ---------- 앱 셸 (디자인시스템 Sidebar: 화이트 212px, wm/dm과 동일) ---------- */
.app { display: grid; grid-template-columns: 212px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--surf); border-right: 1px solid var(--line);
  padding: 16px 10px; display: flex; flex-direction: column; gap: 4px;
}
.sidebar .logo {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px 16px; margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.sidebar .logo img { width: 30px; height: 30px; border-radius: var(--r-sm); object-fit: contain; }
.sidebar .logo .lt { line-height: 1.2; }
.sidebar .logo .lt .nm { font-family: Georgia, "Times New Roman", serif; font-size: 17px; font-weight: 700; letter-spacing: .4px; color: var(--p700); }
.sidebar .logo .lt .nm b { font-style: italic; color: var(--p500); font-weight: 700; margin-right: 2px; }
.sidebar .logo .lt small { display: block; font-size: 10px; color: var(--ba40); font-weight: 500; letter-spacing: .3px; margin-top: 1px; }
.sidebar .nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }

/* 폴더형 메뉴 — 앱 하나 = 헤더(접기/펼치기) + 하위 메뉴 목록 */
.nav-folder-head {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: transparent; border: none; border-radius: var(--r-sm); padding: 9px 10px;
  font-size: 13.5px; font-weight: 700; color: var(--ba100); cursor: pointer; font-family: var(--font);
}
.nav-folder-head:hover { background: var(--ba4); }
.nav-folder-head .chevron { font-size: 9px; color: var(--ba40); width: 10px; flex: none; transition: transform .15s; }
.nav-folder.open .nav-folder-head .chevron { transform: rotate(90deg); }
.nav-folder-head .msym { font-size: 17px; color: var(--p600); flex: none; }
.nav-folder-head .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-folder-head .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ba20); flex: none; }
.nav-folder-head .dot.ok { background: var(--success-500); }
.nav-folder-body { display: none; flex-direction: column; gap: 1px; padding: 2px 0 6px; }
.nav-folder.open .nav-folder-body { display: flex; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: none; border-radius: var(--r-sm); padding: 8px 10px 8px 32px;
  font-size: 13px; font-weight: 500; color: var(--ba80); cursor: pointer; font-family: var(--font);
  white-space: nowrap;
}
.nav-item:hover { background: var(--ba4); }
.nav-item.active { background: var(--p50); color: var(--p700); font-weight: 700; }
.nav-item .msym { font-size: 16px; flex: none; }

.main { display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }
.appbar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 28px; background: var(--surf); border-bottom: 1px solid var(--line); }
.appbar .crumb { font-weight: 700; font-size: 16px; color: var(--ba100); }
.appbar-actions { display: flex; align-items: center; gap: 8px; }

/* 자식 화면(모듈)이 알림 메시지를 여기(허브 상단바 가운데)에 띄운다 — window.o2uToast.
 * 항상 가장 위, 항상 보이는 자리라 자식 iframe 안의 다른 버튼에 가려질 일이 없다.
 * 플렉스 흐름에서 빼서(position:absolute) 크럼·사용자 정보 배치에 영향을 주지 않는다. */
.hub-toast {
  position: absolute; left: 50%; top: 50%; z-index: 50; pointer-events: none;
  padding: 8px 18px; border-radius: var(--r-md); font-size: 13px; font-weight: 700;
  color: #fff; background: var(--success-600); box-shadow: var(--shadow-lg);
  transform: translate(-50%, -50%) translateY(-14px); opacity: 0; transition: all .25s;
}
.hub-toast.show { transform: translate(-50%, -50%) translateY(0); opacity: 1; }
.hub-toast.err { background: var(--danger-600); }
.appbar-user {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 12px 4px 4px; margin-right: 4px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surf);
  max-width: 260px;
}
.au-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: var(--ba4); color: var(--ba80); font-size: 13px; font-weight: 700;
}
.au-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.au-name { font-size: 13px; font-weight: 600; color: var(--ba100); }
.au-id { font-size: 11px; color: var(--ba40); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-id:empty { display: none; }

/* 좁은 화면에서는 아이콘만 남긴다 — 브레드크럼과 버튼이 우선이다. */
@media (max-width: 900px) {
  .appbar-user { max-width: none; padding: 4px; }
  .au-text { display: none; }
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surf); cursor: pointer; color: var(--ba80);
}
.icon-btn:hover { background: var(--ba4); }
.icon-btn .msym { font-size: 20px; }

/* ---------- 탭 바 — 메뉴 클릭 시 새 탭으로 열리고, 여러 개를 동시에 유지 ---------- */
.tab-bar { display: none; align-items: flex-end; gap: 2px; padding: 8px 16px 0; background: var(--surf); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab-chip {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 14px;
  border: 1px solid var(--line); border-bottom: none; border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: var(--surf-muted); color: var(--ba40); font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tab-chip:hover { color: var(--ba80); }
.tab-chip.active { background: var(--surf); color: var(--p700); }
.tab-chip .msym { font-size: 15px; }
.tab-close { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; margin-left: 2px; }
.tab-close .msym { font-size: 14px; }
.tab-close:hover { background: var(--ba10); color: var(--ba100); }

.content { flex: 1; position: relative; overflow: hidden; }
.placeholder {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13.5px; text-align: center; padding: 0 40px;
}
.content-iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: none; }

/* ---------- 모달 (dm/static/style.css와 동일 스펙) ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15,25,40,.45); z-index: 1000;
  display: none; align-items: center; justify-content: center; padding: 20px; }
.modal-back.show { display: flex; }
.modal { background: var(--surf); border-radius: var(--r-lg); width: 100%; max-width: 640px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 15px; }
.modal-body { padding: 20px; }

/* ---------- 공용 컴포넌트 (dm/static/style.css와 동일 스펙) ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow-sm); }
.page-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 18px; }
.page-head h1 { font-size: 20px; color: var(--ba100); font-weight: 700; }
.page-head .sub { color: var(--muted); font-size: 12.5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--r-md); padding: 9px 16px; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; font-family: var(--font); white-space: nowrap;
  transition: background .15s, box-shadow .15s;
}
.btn.primary { background: var(--p600); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--p700); }
.btn.ghost { border: 1px solid var(--line); color: var(--ba100); background: var(--surf); }
.btn.ghost:hover { background: var(--ba4); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ba80); }
.field input, .field textarea, .field select {
  border: 1px solid #cbd5e1; border-radius: var(--r-md); padding: 11px 13px; font-size: 13.5px;
  font-family: var(--font); color: var(--ba100); background: var(--surf); width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.field input::placeholder { color: #94a3b8; }
.field input:focus, .field select:focus {
  outline: none; border-color: var(--p400); box-shadow: 0 0 0 3px var(--p50);
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-auto { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.note { font-size: 12px; color: var(--ba40); background: var(--ba4); border-radius: var(--r-sm); padding: 8px 12px; margin-top: 10px; }
.hint { font-size: 11px; color: var(--muted); }
.error-box { background: var(--danger-50); color: var(--danger-600); border: 1px solid #f5c6c0;
  border-radius: var(--r-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 12px; display: none; }
.error-box.show { display: block; }
.loading-text { color: var(--muted); text-align: center; padding: 30px; font-size: 13px; }

@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
}

/* ---------- 대시보드 (로그인 첫 화면) — Design §5 ---------- */
/* 사이드바 맨 위 단일 항목. 폴더 항목과 달리 왼쪽 들여쓰기가 없다. */
.nav-item.nav-root { padding-left: 10px; font-weight: 600; margin-bottom: 6px; }
.nav-item.nav-root .msym { color: var(--p600); }
.nav-item.nav-disabled { opacity: .45; cursor: not-allowed; }
.nav-item.nav-disabled:hover { background: none; }

/* 외부 사이트 표시 — 허브가 기동하지 않는 남의 서버라는 신호 */
.nav-ext { margin-left: auto; font-size: 13px !important; color: var(--ba20) !important; flex: none; }
.nav-folder-head .nav-ext { margin-left: auto; }

/* .content 가 position:relative; overflow:hidden 이라 옛 .placeholder 와 같은 방식으로 채운다. */
.dash {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; gap: 18px;
  padding: 24px 28px 36px; overflow-y: auto;
}
.dash-hello { font-size: 20px; font-weight: 700; color: var(--ba100); }

.dash-tiles { display: flex; flex-wrap: wrap; gap: 12px; }
.dash-tile {
  display: flex; flex-direction: column; gap: 2px; min-width: 132px;
  padding: 14px 18px; text-align: left; cursor: pointer; font-family: var(--font);
  background: var(--surf); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.dash-tile:hover { border-color: var(--p300); }
.dash-tile:disabled { cursor: default; opacity: .55; }
.dash-tile:disabled:hover { border-color: var(--line); }
.dt-num { font-size: 26px; font-weight: 700; color: var(--p600); line-height: 1.1; font-variant-numeric: tabular-nums; }
.dt-label { font-size: 12px; color: var(--ba40); }
.dash-tiles-err { display: none; font-size: 12px; color: var(--danger-600); }

/* "대기 할 일" 타일만 숫자 둘(AI 제안/전체)로 갈라 각각 따로 클릭한다 — 나머지 타일은
   박스 전체가 버튼이지만, 이건 안쪽 숫자 둘만 버튼이라 바깥 박스는 cursor 를 되돌린다. */
.dash-tile-split { cursor: default; }
.dt-split-row { display: flex; align-items: baseline; gap: 7px; }
.dt-split-btn {
  display: flex; flex-direction: column; gap: 2px; align-items: flex-start;
  background: none; border: none; padding: 0; cursor: pointer; font-family: var(--font);
}
.dt-split-btn:hover .dt-num { color: var(--p700); text-decoration: underline; }
.dt-split-btn:disabled { cursor: default; }
.dt-split-btn:disabled .dt-num { color: var(--p600); text-decoration: none; }
.dt-split-sep { color: var(--ba40); font-size: 16px; }
.dt-sub { font-size: 10.5px; color: var(--ba40); }

.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.dash-card {
  display: flex; flex-direction: column; min-width: 0;
  background: var(--surf); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.dash-card > header {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.dash-card > header h2 {
  display: flex; align-items: center; gap: 7px;
  font-size: 13.5px; font-weight: 700; color: var(--ba100);
}
.dash-card > header h2 .msym { font-size: 17px; color: var(--p600); }
.dash-card-body { padding: 6px 0; min-height: 96px; }

.dash-list { list-style: none; }
.dash-list li { padding: 9px 16px; cursor: pointer; border-bottom: 1px solid var(--ba4); }
.dash-list li:last-child { border-bottom: none; }
.dash-list li:hover { background: var(--ba4); }
.dl-title { display: block; font-size: 13px; color: var(--ba100); line-height: 1.45; }
.dl-meta { display: block; margin-top: 2px; font-size: 11px; color: var(--ba40); }
.dash-empty, .dash-err { padding: 24px 16px; text-align: center; font-size: 12.5px; color: var(--ba40); }
.dash-err { color: var(--danger-600); }

/* Design §5.3 — 준비 중 카드. 숫자·목록 없음, 커서도 기본값, 클릭 핸들러 없음. */
.dash-card.soon { opacity: .62; background: var(--surf-muted); }
.dash-card.soon > header h2 .msym { color: var(--ba40); }
.soon-badge {
  flex: none; font-size: 10.5px; font-weight: 700; color: var(--ba40);
  padding: 2px 8px; border: 1px solid var(--line); border-radius: var(--r-full); background: var(--surf);
}
.soon-desc { padding: 16px; font-size: 12px; color: var(--ba40); line-height: 1.6; }

@media (max-width: 1100px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .dash { padding: 18px 16px 28px; }
  .dash-grid { grid-template-columns: 1fr; }
}
