/* =====================================================================
   한올 — Desktop App Shell (Buyer/Seller/Admin 공용 데스크톱)
   딥 인디고 사이드바 + 라이트 콘텐츠 · 데이터 콘솔 톤
   tokens.css / ui.css 위에 얹어 사용
   ===================================================================== */

.dapp { display: grid; grid-template-columns: 224px 1fr; grid-template-rows: minmax(0, 1fr); height: 100vh; overflow: hidden; }

/* ---------- Sidebar ---------- */
.dside { background: var(--primary-900); color: rgba(255,255,255,.72); display: flex; flex-direction: column; min-height: 0; }
.dside-logo { display: flex; align-items: center; gap: 10px; padding: 16px 14px 12px; }
.dside-logo .mk { width: 34px; height: 34px; border-radius: 10px; background: #fff; color: var(--primary-800); display: grid; place-items: center; font-size: 14px; font-weight: 800; letter-spacing: -.06em; flex: none; }
.dside-logo .nm { color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -.02em; line-height: 1.1; }
.dside-logo .role { font-size: 11px; font-weight: 700; color: rgba(255,255,255,.55); margin-top: 1px; }
.dside-sec { font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.38); padding: 14px 16px 6px; }
.dside-nav { flex: 1; overflow: auto; padding: 6px 10px 12px; }
.dside-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 11px; border-radius: 9px; border: 0; background: none; cursor: pointer;
  color: rgba(255,255,255,.74); font-family: inherit; font-size: 13.5px; font-weight: 600; text-align: left; transition: background .13s, color .13s; position: relative; }
.dside-item svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.dside-item span { white-space: nowrap; }
.dside-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.dside-item.active { background: rgba(255,255,255,.13); color: #fff; }
.dside-item.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary-300); }
.dside-item .cnt { margin-left: auto; font-size: 11px; font-weight: 700; background: var(--primary-500); color: #fff; padding: 1px 7px; border-radius: 99px; }
.dside-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.1); }
.dside-foot a { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 10px; color: rgba(255,255,255,.6); font-size: 13px; font-weight: 600; text-decoration: none; }
.dside-foot a:hover { background: rgba(255,255,255,.08); color: #fff; }
.dside-user { display: flex; align-items: center; gap: 10px; padding: 9px 12px; }
.dside-user .av { width: 30px; height: 30px; border-radius: 99px; background: var(--primary-500); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.dside-user .un { color: #fff; font-size: 13px; font-weight: 650; }
.dside-user .ur { color: rgba(255,255,255,.5); font-size: 11px; }

/* ---------- Main ---------- */
.dmain { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.dtop { height: 62px; flex: none; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; gap: 16px; }
.dtop-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dtop .backbtn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text-2); flex: none; }
.dtop .backbtn:hover { background: var(--surface-3); color: var(--text); }
.dtop .backbtn[disabled] { opacity: .4; pointer-events: none; }
.dtop .crumb { font-size: 12.5px; color: var(--text-3); }
.dtop .crumb b { color: var(--text); font-weight: 700; }
.dtop h1 { font-size: 18px; font-weight: 750; letter-spacing: -.02em; margin: 0; white-space: nowrap; }
.dtop-r { display: flex; align-items: center; gap: 8px; }
.dtop-r .ic { width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--text-2); }
.dtop-r .ic:hover { background: var(--surface-3); }

.dbody { flex: 1; overflow: auto; min-height: 0; }
/* compact in-table input (소싱 폼) */
.cin { width: 100%; height: 32px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 7px; font-family: inherit; font-size: 12.5px; background: var(--surface); color: var(--text); }
.cin:focus { outline: none; border-color: var(--primary-500); box-shadow: 0 0 0 2px var(--primary-100); }
select.cin { appearance: none; padding-right: 6px; }
.dpage { padding: 26px 30px 48px; max-width: 1440px; margin-inline: auto; }
.dpage.narrow { max-width: 1080px; }
.dpage-head { margin-bottom: 20px; }
.dpage-head h2 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
.dpage-head p { color: var(--text-2); font-size: 14px; margin: 0; }

/* ---------- Stat cards ---------- */
.dstats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.dstat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; min-width: 0; }
.dstat .k { font-size: 13px; color: var(--text-3); font-weight: 600; display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.dstat .k svg { flex: none; }
.dstat .v { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dstat .d { font-size: 12px; margin-top: 5px; font-weight: 650; }
.dstat .d.up { color: var(--ok-fg); } .dstat .d.down { color: var(--danger-fg); }

/* ---------- Panels / layout ---------- */
.dpanel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.dpanel-hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.dpanel-hd h3 { font-size: 15px; font-weight: 750; margin: 0; }
.dpanel-bd { padding: 18px; }
.dtwo { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
@media (max-width: 1100px){ .dtwo { grid-template-columns: 1fr; } }

/* §1 제작 전환 제안 카드 (buyer-conversion) — 인라인 고정 그리드 대체 + 모바일 1열 */
.conv-two  { grid-template-columns: 260px 1fr; }
.conv-calc { grid-template-columns: 1.15fr .85fr; }
.conv-trig { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 820px){ .conv-trig { grid-template-columns: 1fr; } }
@media (max-width: 760px){ .conv-two, .conv-calc { grid-template-columns: 1fr; } }
/* §3 운영 콕핏 작업 행 — 좁은 화면에서 도메인 배지·CTA가 둘째 줄로 */
@media (max-width: 600px){
  .cockpit-row { flex-wrap: wrap; row-gap: 10px; }
  .cockpit-row > div { flex: 1 1 calc(100% - 52px); }
  .cockpit-row > .btn { margin-left: auto; }
}
/* 전환 제안 카드 푸터 — 모바일에서 버튼 풀폭 분할 */
@media (max-width: 560px){
  .conv-foot-actions { width: 100%; }
  .conv-foot-actions .btn { flex: 1; }
}
/* 전환 제안 카드 — 자세히 토글 버튼 */
.conv-expand { width: 100%; border: 0; border-top: 1px solid var(--border); background: var(--surface);
  cursor: pointer; font-family: inherit; font-size: 12.5px; font-weight: 700; color: var(--primary-700);
  padding: 11px 14px; display: flex; align-items: center; justify-content: center; gap: 6px; transition: background .13s; }
.conv-expand:hover { background: var(--primary-50); }

/* ---------- Tabs ---------- */
.dtabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.dtab { padding: 10px 14px; border: 0; background: none; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 650; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.dtab:hover { color: var(--text); }
.dtab.active { color: var(--primary-700); border-bottom-color: var(--primary-600); }

/* ---------- Toolbar (filters above tables) ---------- */
.dtoolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.dsearch { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.dsearch input { width: 100%; height: 38px; border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 12px 0 36px; font-family: inherit; font-size: 14px; background: var(--surface); }
.dsearch input:focus { outline: none; border-color: var(--primary-500); box-shadow: 0 0 0 3px var(--primary-100); }
.dsearch svg { position: absolute; left: 11px; top: 10px; width: 17px; height: 17px; color: var(--text-3); }

/* ---------- Right Drawer (transition 프리즈에도 안전) ---------- */
.ddrawer-wrap { position: fixed; inset: 0; z-index: 90; }
.ddrawer-wrap:not(.open) { display: none; }
.ddrawer-scrim { position: absolute; inset: 0; background: rgba(20,28,40,.42); animation: scrimIn .2s ease; }
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }
.ddrawer { position: absolute; top: 0; right: 0; bottom: 0; width: 460px; max-width: 92vw; background: var(--surface); box-shadow: -10px 0 40px rgba(0,0,0,.18);
  display: flex; flex-direction: column; animation: drawerIn .26s cubic-bezier(.22,1,.36,1); }
@keyframes drawerIn { from { transform: translateX(46px); } to { transform: none; } }
.ddrawer-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.ddrawer-bd { flex: 1; overflow: auto; padding: 20px; }
.ddrawer-ft { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; }

/* doc/file tiles, KV grid */
.dkv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 13.5px; }
.dkv dt { color: var(--text-3); }
.dkv dd { margin: 0; font-weight: 600; text-align: right; }
.dlist-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); min-width: 0; }
.dlist-row:last-child { border-bottom: 0; }
/* 행 트레일링 배지/버튼은 고정폭, 텍스트측이 먼저 줄어들어 배지가 카드 밖으로 밀리거나
   overflow:hidden 패널에서 잘리지 않게 한다 (라벨이 길거나 EN/中 로케일에서도 안전). */
.dlist-row > :first-child { min-width: 0; }
.dlist-row > :last-child { flex: none; }
/* 한 줄 라벨은 말줄임 처리(가장 깔끔한 데스크톱 리스트 UX) */
.dlist-row .lr-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* =====================================================================
   Responsive layer  (Buyer / Seller / Admin 공용)
   1) 사이드바 → 오프캔버스 드로어 (햄버거)  2) 2-pane·폼 그리드 유틸
   ===================================================================== */

/* ---- 반응형 레이아웃 유틸 그리드 (인라인 고정 그리드 대체) ---- */
.r-split  { display: grid; grid-template-columns: minmax(0, 1fr) var(--aside, 400px); gap: 28px; align-items: start; }
.rfq-split{ display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
/* r2·r3 — 컨테이너가 좁으면 자동으로 줄 수를 줄여 카드 짓눌림 방지 */
.r2   { display: grid; grid-template-columns: repeat(auto-fit, minmax(208px, 1fr)); gap: 14px; }
.r3   { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.r2sm { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.r3sm { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.branch-grid   { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.r-aside-sticky{ position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow: auto; }
/* 공급 공장 카드 — 좁으면 정보 블록을 세로로 */
@media (max-width: 560px) { .r-supply { grid-template-columns: 1fr !important; } }

/* ---- 언어·통화 스위처 (앱바) ---- */
.locale-wrap { position: relative; flex: none; }
.locale-btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 9px 0 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text-2); font-family: inherit; font-size: 13px; font-weight: 650; }
.locale-btn:hover, .locale-btn.open { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.locale-btn > svg { color: var(--text-3); }
.locale-btn .lc-val { color: var(--text); letter-spacing: .01em; }
.locale-btn .lc-sep { width: 1px; height: 14px; background: var(--border-strong); }
.locale-btn .lc-chev { transition: transform .16s; }
.locale-btn.open .lc-chev { transform: rotate(180deg); }
.locale-pop { position: absolute; top: calc(100% + 8px); right: 0; z-index: 200; width: 236px; background: var(--surface); border: 1px solid var(--border); border-radius: 13px; box-shadow: var(--shadow-lg); padding: 12px; animation: lcPop .16s ease; }
@keyframes lcPop { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: none; } }
.lc-grp-t { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin: 4px 2px 8px; }
.lc-seg { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.lc-seg + .lc-grp-t { margin-top: 14px; }
.lc-opt { display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 4px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2); transition: background .12s, border-color .12s, color .12s; white-space: nowrap; }
.lc-opt:hover { border-color: var(--primary-300); color: var(--text); }
.lc-opt.on { background: var(--primary-700); border-color: var(--primary-700); color: #fff; }

/* ---- 햄버거 + 스크림 (데스크톱 기본 숨김) ---- */
.dtop .hamb { display: none; width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); place-items: center; cursor: pointer; color: var(--text-2); flex: none; }
.dtop .hamb:hover { background: var(--surface-3); color: var(--text); }
.dnav-scrim { display: none; }

/* ===== 1025–1280px : 좁은 데스크톱 — 우측 aside(계산기·미리보기) 폭 축소 ===== */
@media (min-width: 1025px) and (max-width: 1280px) {
  /* 인라인 --aside(420px 등)를 덮어써 계산기 폭을 줄이고 좌측 본문에 여유 확보 */
  .r-split { grid-template-columns: minmax(0, 1fr) clamp(320px, 32vw, 380px); gap: 22px; }
}

/* ===== ≤1024px : 태블릿 — 사이드바 오프캔버스 · 2-pane 스택 ===== */
@media (max-width: 1024px) {
  .dapp { grid-template-columns: 1fr; }
  .dside { position: fixed; top: 0; left: 0; bottom: 0; width: 272px; z-index: 220;
    transform: translateX(-100%); transition: transform .28s cubic-bezier(.22, 1, .36, 1); box-shadow: 12px 0 44px rgba(0, 0, 0, .28); }
  .dapp.nav-open .dside { transform: none; }
  .dnav-scrim { display: block; position: fixed; inset: 0; z-index: 210; background: rgba(20, 28, 40, .46);
    opacity: 0; pointer-events: none; transition: opacity .24s; }
  .dapp.nav-open .dnav-scrim { opacity: 1; pointer-events: auto; }
  .dtop .hamb { display: grid; }
  .dtwo { grid-template-columns: 1fr; }
  .r-split, .rfq-split { grid-template-columns: 1fr; gap: 20px; }
  .r-aside-sticky { position: static; }
  .branch-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== ≤860px : 3-열 폼 → 2-열 ===== */
@media (max-width: 860px) {
  .r3, .r3sm { grid-template-columns: 1fr 1fr; }
}

/* ===== ≤760px : 모바일 — 패딩 축소 · 표 가로 스크롤 ===== */
@media (max-width: 760px) {
  .dpage { padding: 18px 15px 40px; }
  .dpage.narrow { max-width: 100%; }
  .dpage-head { flex-wrap: wrap; }
  .dpage-head h2 { font-size: 20px; }
  .dtop { height: 56px; padding: 0 12px; gap: 10px; }
  .dtop h1 { font-size: 16px; max-width: 52vw; overflow: hidden; text-overflow: ellipsis; }
  .dtop .crumb { display: none; }
  .dstat .v { font-size: 22px; }
  /* 데이터 표는 패널 안에서 가로 스크롤 (열 가독성 유지) */
  .dpanel:has(> table.dt) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .dpanel:has(> table.dt) .dt { min-width: 640px; }
}

/* =====================================================================
   거래 모니터링 — 마스터·디테일 분할
   행 선택 시 표를 좁히고 디테일을 옆에 도킹(데스크톱) / 오버레이(좁은 화면)
   ===================================================================== */
.mon-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.mon-split.has-detail { grid-template-columns: minmax(0, 1fr) minmax(380px, 432px); }
.mon-table { overflow: hidden; }
.mon-table.scrollx { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mon-table .dt { min-width: 0; }
.mon-split.has-detail .mon-table .dt { min-width: 560px; }
.dt tr.sel > td { background: var(--primary-50); }
.dt tr.sel > td:first-child { box-shadow: inset 3px 0 0 var(--primary-500); }

.mon-detail { position: sticky; top: 0; align-self: start; max-height: calc(100vh - 62px - 74px); overflow: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  display: flex; flex-direction: column; animation: monDetailIn .24s cubic-bezier(.22, 1, .36, 1); }
@keyframes monDetailIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.mon-detail-hd { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.mon-detail-bd { padding: 18px 20px 22px; }
.mon-scrim { display: none; }

@media (max-width: 1200px) {
  .mon-split.has-detail { grid-template-columns: minmax(0, 1fr); }
  .mon-scrim { display: block; position: fixed; inset: 0; z-index: 90; background: rgba(20, 28, 40, .42); animation: scrimIn .2s ease; }
  .mon-detail { position: fixed; top: 0; right: 0; bottom: 0; z-index: 91; width: min(440px, 92vw);
    max-height: none; border-radius: 0; border: 0; box-shadow: -10px 0 40px rgba(0, 0, 0, .18);
    animation: drawerIn .26s cubic-bezier(.22, 1, .36, 1); }
}

/* ===== ≤640px : 폰 — 모든 다열 그리드 1열 ===== */
@media (max-width: 640px) {
  .r2, .r3, .r2sm, .r3sm, .branch-grid { grid-template-columns: 1fr; }
}

/* ===== ≤560px : 상단 장식 아이콘 숨김 ===== */
@media (max-width: 560px) {
  .dtop-r .ic { display: none; }
}

/* ---------- 모바일 하단 탭바 (옵션 · bottomTabs 전달 시) ---------- */
.dbottomnav { display: none; flex: none; align-items: stretch; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0); z-index: 60; }
.dbtab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 0; background: none; cursor: pointer; padding: 9px 4px 8px; color: var(--text-3); font-family: inherit;
  font-size: 11px; font-weight: 650; position: relative; transition: color .13s; }
.dbtab svg { opacity: .8; }
.dbtab.active { color: var(--primary-700); }
.dbtab.active svg { opacity: 1; }
.dbtab .dbtab-dot { position: absolute; top: 7px; right: calc(50% - 16px); width: 7px; height: 7px; border-radius: 99px; background: var(--primary-500); border: 1.5px solid var(--surface); }

/* 폰 폭: 하단 탭바 노출 · 햄버거 숨김(탭바가 1차 내비) */
@media (max-width: 640px) {
  .dbottomnav { display: flex; }
  .dapp.has-bottomtabs .dtop .hamb { display: none; }
}
