/* ==========================================================
   비즈맵 ERP — 디자인 시스템
   ========================================================== */
:root {
  --primary: #2b59ff;
  --primary-ink: #1c41d8;
  --primary-soft: #eef2ff;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #667085;
  --muted-2: #98a2b3;
  --line: #e4e7ec;
  --line-2: #d0d5dd;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --ok: #12b76a;
  --ok-soft: #ecfdf3;
  --warn: #f79009;
  --warn-soft: #fffaeb;
  --danger: #f04438;
  --danger-soft: #fef3f2;
  --info: #2e90fa;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 2px 6px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 12px 28px -8px rgba(16, 24, 40, .16), 0 2px 6px rgba(16, 24, 40, .05);
  --shadow-lg: 0 24px 60px -12px rgba(16, 24, 40, .24);
  --font: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
  --mono: 'SFMono-Regular', ui-monospace, 'Cascadia Mono', 'Consolas', monospace;
  --header-h: 64px;
}

* { box-sizing: border-box; }
svg { width: 16px; height: 16px; flex: none; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
::selection { background: color-mix(in srgb, var(--primary) 22%, transparent); }

/* 스크롤바 */
* { scrollbar-width: thin; scrollbar-color: #c8cfda transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: #c8cfda; border-radius: 8px; border: 2px solid var(--bg); }

.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #fff; color: var(--ink-2); font-weight: 600; font-size: 13.5px;
  white-space: nowrap; transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: #f9fafb; border-color: #b6bfcd; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 92%, #fff), var(--primary));
  border-color: transparent; color: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.12), inset 0 1px 0 rgba(255,255,255,.22);
}
.btn.primary:hover { background: linear-gradient(180deg, var(--primary), var(--primary-ink)); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: rgba(16,24,40,.05); }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-ink); box-shadow: none; }
.btn.soft:hover { background: color-mix(in srgb, var(--primary) 14%, #fff); }
.btn.danger { color: var(--danger); border-color: #fecdca; background: #fff; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: transparent; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn.xs { height: 27px; padding: 0 9px; font-size: 11.5px; border-radius: 7px; gap: 4px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.xs svg { width: 14px; height: 14px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--ink-2);
}
.icon-btn:hover { background: rgba(16,24,40,.06); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.bordered { border-color: var(--line-2); background: #fff; box-shadow: var(--shadow-xs); }

/* ---------- 배지 · 칩 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: -.01em;
  background: #f2f4f7; color: var(--ink-2); border: 1px solid transparent; white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: #067647; }
.badge.warn { background: var(--warn-soft); color: #b54708; }
.badge.bad { background: var(--danger-soft); color: #b42318; }
.badge.info { background: #eff8ff; color: #175cd3; }
.badge.line { background: #fff; border-color: var(--line-2); color: var(--muted); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-weight: 650; font-size: 13.5px;
  transition: all .15s;
}
.chip svg { width: 17px; height: 17px; }
.chip:hover { border-color: var(--line-2); background: #fcfcfd; }
.chip.active { background: var(--ink); color: #fff; border-color: var(--ink); box-shadow: 0 6px 14px -6px rgba(16,24,40,.4); }
.chip.sm { height: 31px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }

/* ---------- 입력 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 12.5px; font-weight: 650; color: var(--ink-2); letter-spacing: -.01em; }
.field .hint { font-size: 11.5px; color: var(--muted-2); font-weight: 500; margin-left: 4px; }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2);
  background: #fff; color: var(--ink); font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3.5px color-mix(in srgb, var(--primary) 16%, transparent);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input.sm, .select.sm { height: 34px; font-size: 13px; border-radius: 8px; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
select.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .third { grid-column: span 1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- 카드 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.card.pad { padding: 20px; }
.card-h { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.card-h h3 { font-size: 15px; font-weight: 750; letter-spacing: -.02em; }
.card-b { padding: 20px; }

/* ---------- 앱 셸 ---------- */
.app-root { min-height: 100%; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 30; height: var(--header-h); flex: none;
  display: flex; align-items: center; gap: 18px; padding: 0 20px;
  background: rgba(255,255,255,.86); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex: none; display: grid; place-items: center;
  background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 86%, #fff), var(--primary-ink));
  color: #fff; font-weight: 800; font-size: 18px; box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--primary) 60%, transparent);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-text { min-width: 0; }
.brand-name { display: block; font-size: 15px; font-weight: 800; letter-spacing: -.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: -1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; align-items: center; gap: 2px; margin-left: 6px; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; border-radius: 9px;
  color: var(--muted); font-weight: 650; font-size: 13.5px; white-space: nowrap;
}
.nav a svg { width: 17px; height: 17px; }
.nav a:hover { background: rgba(16,24,40,.05); color: var(--ink-2); }
.nav a.active { background: var(--primary-soft); color: var(--primary-ink); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; border-radius: 999px; border: 1px solid var(--line); background: #fff; }
.user-chip .nm { font-size: 12.5px; font-weight: 650; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary-ink); font-weight: 800; font-size: 12px;
}
.main { flex: 1; padding: 22px 24px 60px; max-width: 1460px; width: 100%; margin: 0 auto; }
@media (max-width: 980px) {
  .app-header { gap: 10px; padding: 0 12px; height: 60px; }
  .nav { display: none; }
  .header-right .user-chip .nm { display: none; }
  .main { padding: 14px 12px 92px; }
}
.mobile-nav { display: none; }
@media (max-width: 980px) {
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(255,255,255,.94); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 5px 0;
    color: var(--muted); font-size: 10.5px; font-weight: 650; border-radius: 10px;
  }
  .mobile-nav a svg { width: 21px; height: 21px; }
  .mobile-nav a.active { color: var(--primary-ink); }
  .mobile-nav a.active svg { stroke-width: 2.2; }
}

/* ---------- 페이지 헤더 ---------- */
.page-head { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.page-title { font-size: 23px; font-weight: 800; letter-spacing: -.045em; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- 대시보드 통계 ---------- */
.stat-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 15px 13px;
  box-shadow: var(--shadow-xs); position: relative; overflow: hidden; min-width: 0;
}
.stat .lb { font-size: 11.5px; color: var(--muted); font-weight: 650; display: flex; align-items: center; gap: 5px; }
.stat .lb svg { width: 14px; height: 14px; }
.stat .vv { font-size: 22px; font-weight: 800; letter-spacing: -.04em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .vv small { font-size: 12px; font-weight: 700; color: var(--muted); margin-left: 3px; }
.stat .sub { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.stat.warn .vv { color: #b54708; }
.stat.bad .vv { color: #b42318; }
.stat::after { content: ""; position: absolute; right: -22px; top: -22px; width: 70px; height: 70px; border-radius: 50%; background: var(--primary-soft); opacity: .55; }
.stat.warn::after { background: var(--warn-soft); }
.stat.bad::after { background: var(--danger-soft); }
@media (max-width: 1100px) {
  .stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 700px) {
  .stat-row { display: flex; overflow-x: auto; gap: 10px; margin: 0 -12px 12px; padding: 2px 12px 8px; scroll-snap-type: x mandatory; }
  .stat { flex: 0 0 152px; scroll-snap-align: start; }
  .stat .vv { font-size: 19px; }
}

/* ---------- 지도 ---------- */
.map-shell {
  position: relative; background: #fff; border: 1px solid var(--line); border-radius: 18px; overflow: hidden;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column;
}
.map-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; background: #fff; }
.map-toolbar .chips { display: flex; gap: 6px; }
.map-toolbar .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.map-body { position: relative; background:
    radial-gradient(circle at 18% 12%, #eef3ff 0%, transparent 46%),
    radial-gradient(circle at 88% 88%, #eefaf4 0%, transparent 42%),
    #fbfcfe;
  height: clamp(420px, calc(100vh - 336px), 700px); touch-action: none; overflow: hidden;
}
.map-body::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(#dfe5ef 1px, transparent 1px); background-size: 22px 22px; opacity: .55;
}
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.map-svg.dragging { cursor: grabbing; }
.map-hud { display: contents; }
.map-legend { position: absolute; left: 12px; top: 12px; z-index: 4; background: rgba(255,255,255,.94); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: 12px; padding: 9px 11px; box-shadow: var(--shadow-sm); font-size: 11.5px; }
.map-legend .lg-row { display: flex; align-items: center; gap: 7px; padding: 2px 0; color: var(--ink-2); cursor: pointer; user-select: none; }
.map-legend .lg-row.off { opacity: .38; }
.map-legend .lg-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.map-legend .lg-sq { width: 9px; height: 9px; border-radius: 2.5px; flex: none; }
.map-zoom { position: absolute; left: 12px; bottom: 12px; z-index: 4; display: flex; gap: 4px; background: rgba(255,255,255,.95); border: 1px solid var(--line); border-radius: 10px; padding: 4px; box-shadow: var(--shadow-sm); }
.map-zoom button { width: 32px; height: 32px; border: 0; background: transparent; border-radius: 7px; display: grid; place-items: center; color: var(--ink-2); }
.map-zoom button:hover { background: #f2f4f7; }
.map-zoom svg { width: 17px; height: 17px; }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; }
.map-empty .inner { max-width: 320px; }
.map-empty h3 { font-size: 16px; font-weight: 750; margin-bottom: 6px; }
.map-empty p { font-size: 13px; color: var(--muted); line-height: 1.6; }

.map-panel[hidden] { display: none; }
.map-shell:fullscreen, .map-shell.is-full {
  border-radius: 0; border: 0; width: 100vw; height: 100vh; background: #fff;
}
.map-shell.is-full { position: fixed; inset: 0; z-index: 80; }
.map-shell:fullscreen .map-body, .map-shell.is-full .map-body { flex: 1; height: auto; min-height: 0; }
.map-shell:fullscreen .map-toolbar, .map-shell.is-full .map-toolbar { padding: 8px 12px; }
.map-shell:fullscreen .map-panel, .map-shell.is-full .map-panel { top: 62px; }
.map-floats { display: none; position: absolute; left: 12px; bottom: 12px; z-index: 6; flex-direction: column; gap: 6px; }
.map-floats .icon-btn { width: 38px; height: 38px; background: rgba(255,255,255,.95); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.map-shell:fullscreen .map-floats, .map-shell.is-full .map-floats { display: flex; }
.map-shell:fullscreen .map-legend, .map-shell.is-full .map-legend,
.map-shell:fullscreen .map-zoom, .map-shell.is-full .map-zoom { display: none; }
.map-shell.forced { display: flex; align-items: center; justify-content: center; }
.map-shell.forced .map-toolbar { display: none; }
.map-shell.forced .map-body {
  position: relative; inset: auto; flex: none;
  width: var(--rot-w, 100vh); height: var(--rot-h, 100vw); min-height: 0;
  transform: rotate(90deg); transform-origin: center center;
}
.map-shell.forced .map-panel { top: 10px; }

/* 지도 노드 */
.g-node { cursor: grab; }
.g-node.dragging { cursor: grabbing; }
.map-svg .g-node .node-label, .map-svg .g-node .node-sub { transition: opacity .18s; }
.map-svg[data-map-mode="customer"]:not(.zoom-labels) .g-node[data-type="as"] .node-label,
.map-svg[data-map-mode="customer"]:not(.zoom-labels) .g-node[data-type="as"] .node-sub,
.map-svg[data-map-mode="process"]:not(.zoom-labels) .g-node[data-type="as"] .node-label,
.map-svg[data-map-mode="process"]:not(.zoom-labels) .g-node[data-type="as"] .node-sub { opacity: 0; pointer-events: none; }
.g-node text { pointer-events: none; }
.g-node .node-label, .g-node .node-sub { pointer-events: auto; }
.g-node .node-label { font-size: 11px; font-weight: 700; fill: #344054; text-anchor: middle; paint-order: stroke; stroke: #fbfcfe; stroke-width: 4px; stroke-linejoin: round; }
.g-node .node-sub { font-size: 9.5px; font-weight: 600; fill: #98a2b3; text-anchor: middle; paint-order: stroke; stroke: #fbfcfe; stroke-width: 4px; }
.g-node:hover .node-core { filter: brightness(.97); }
.g-node.selected .node-core { stroke: var(--ink); stroke-width: 3; }
.link-line { fill: none; stroke-width: 1.6; opacity: .55; }
.link-line.as { stroke-dasharray: 4 4; }
.node-core { transition: filter .15s; }
.pulse-ring { animation: pulse 2.2s ease-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes pulse { 0% { opacity: .55; transform: scale(.92); } 70% { opacity: 0; transform: scale(1.35); } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pulse-ring { animation: none; opacity: 0; } }

/* 지도 상세 패널 */
.map-panel {
  position: absolute; top: 72px; right: 10px; bottom: 10px; width: 356px; max-width: calc(100% - 20px);
  background: rgba(255,255,255,.98); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; z-index: 5; overflow: hidden;
  animation: slideIn .18s ease-out;
}
@keyframes slideIn { from { transform: translateX(12px); opacity: 0; } to { transform: none; opacity: 1; } }
.map-panel-h { display: flex; align-items: flex-start; gap: 10px; padding: 15px 15px 12px; border-bottom: 1px solid var(--line); }
.map-panel-h h3 { font-size: 16px; font-weight: 800; letter-spacing: -.03em; line-height: 1.3; }
.map-panel-b { padding: 14px 15px 18px; overflow: auto; flex: 1; }
.map-panel-f { padding: 10px 12px; border-top: 1px solid var(--line); display: flex; gap: 6px; flex-wrap: wrap; background: var(--surface-2); }
@media (max-width: 700px) {
  .map-panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 62%; border-radius: 16px; }
  .map-panel-b { padding-bottom: 18px; }
  .map-legend { display: none; }
  .map-toolbar { padding: 8px; gap: 6px; }
  .map-toolbar #mapHint { display: none; }
  .map-body { min-height: 380px; height: 56vh; }
  .page-head { margin-bottom: 12px; gap: 8px; }
  .page-title { font-size: 21px; }
  .page-actions { width: auto; margin-left: auto; }
  .page-actions .btn { flex: none; }
  .page-actions .btn .lbl { display: none; }
  .hide-mobile { display: none !important; }
  .map-svg[data-map-mode="customer"]:not(.zoom-labels) .g-node[data-type="product"] .node-label,
  .map-svg[data-map-mode="customer"]:not(.zoom-labels) .g-node[data-type="product"] .node-sub { opacity: 0; pointer-events: none; }
}

.kv { display: flex; gap: 10px; padding: 5px 0; font-size: 12.5px; }
.kv .k { color: var(--muted); min-width: 74px; flex: none; }
.kv .v { color: var(--ink-2); font-weight: 600; word-break: break-all; }
.panel-sec { margin-top: 14px; }
.panel-sec h4 { font-size: 11.5px; font-weight: 750; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin-bottom: 7px; }
.mini-item { display: flex; align-items: center; gap: 9px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.mini-item:last-child { border-bottom: 0; }
.mini-item .mi-main { min-width: 0; flex: 1; }
.mini-item .mi-t { font-size: 12.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-item .mi-s { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 표 ---------- */
.table-wrap { overflow: auto; border-radius: var(--radius); }
table.tb { width: 100%; min-width: 680px; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.tb th {
  text-align: left; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 11px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.tb td { padding: 12px 14px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
table.tb tbody tr:last-child td { border-bottom: 0; }
table.tb tbody tr { transition: background .12s; cursor: pointer; }
table.tb tbody tr:hover { background: #fbfcfe; }
table.tb td.right, table.tb th.right { text-align: right; }
table.tb td.center, table.tb th.center { text-align: center; }
table.tb .doc-no { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
table.tb .doc-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
table.tb .money { font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: .35; transition: opacity .15s; }
tr:hover .row-actions { opacity: 1; }

/* 모바일 카드 목록 */
.list-cards { display: flex; flex-direction: column; gap: 8px; }
.list-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; box-shadow: var(--shadow-xs); }
.list-card .lc-top { display: flex; align-items: center; gap: 8px; }
.list-card .lc-title { font-weight: 750; font-size: 13.5px; }
.list-card .lc-meta { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; margin-top: 5px; flex-wrap: wrap; }

/* ---------- 서류 편집 ---------- */
.doc-editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1080px) { .doc-editor { grid-template-columns: 1fr; } }
.editor-items { width: 100%; border-collapse: collapse; font-size: 13px; }
.editor-items th { font-size: 11px; color: var(--muted); font-weight: 700; text-align: left; padding: 6px 6px; }
.editor-items td { padding: 3px 4px; }
.editor-items .input { height: 36px; font-size: 13px; border-radius: 8px; }
.editor-items .drag { color: var(--muted-2); cursor: grab; width: 22px; text-align: center; }
.items-wrap { overflow-x: auto; }
.items-wrap table { min-width: 620px; }
.totals { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; background: var(--surface-2); border-radius: 12px; border: 1px solid var(--line); }
.totals .trow { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); }
.totals .trow b { font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 1px dashed var(--line-2); margin-top: 4px; padding-top: 9px; font-size: 15px; font-weight: 800; color: var(--ink); }
.totals .grand b { color: var(--primary-ink); font-size: 18px; }
.side-card { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 1080px) { .side-card { position: static; } }
.action-list { display: flex; flex-direction: column; gap: 7px; }

/* ---------- 빈 상태 ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ico { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.empty .ico svg { width: 26px; height: 26px; }
.empty h3 { font-size: 15.5px; font-weight: 750; color: var(--ink); margin-bottom: 5px; }
.empty p { font-size: 13px; line-height: 1.6; max-width: 360px; margin: 0 auto 16px; }

/* ---------- 인증 화면 ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr; background: #fff; }
.auth-visual {
  position: relative; overflow: hidden; color: #fff; padding: 46px;
  background: radial-gradient(120% 90% at 15% 8%, #2748c9 0%, #10225e 52%, #0a1533 100%);
  display: flex; flex-direction: column;
}
.auth-visual::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.055) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.055) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(80% 70% at 40% 40%, #000 40%, transparent 100%);
}
.auth-visual .av-brand { display: flex; align-items: center; gap: 11px; position: relative; z-index: 1; }
.auth-visual .av-brand .bm { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.14); display: grid; place-items: center; font-weight: 800; font-size: 19px; border: 1px solid rgba(255,255,255,.18); }
.auth-visual h1 { font-size: 34px; line-height: 1.28; letter-spacing: -.045em; font-weight: 800; margin-top: 54px; position: relative; z-index: 1; max-width: 420px; }
.auth-visual h1 em { font-style: normal; color: #9db4ff; }
.auth-visual .av-desc { margin-top: 14px; color: #b7c6ea; font-size: 14px; line-height: 1.7; max-width: 400px; position: relative; z-index: 1; }
.auth-visual .av-points { margin-top: 30px; display: flex; flex-direction: column; gap: 11px; position: relative; z-index: 1; }
.auth-visual .av-points div { display: flex; gap: 10px; align-items: center; font-size: 13px; color: #d5def4; }
.auth-visual .av-points svg { width: 18px; height: 18px; color: #8ea9ff; flex: none; }
.auth-art { position: relative; z-index: 1; margin-top: auto; height: 210px; }
.auth-art svg { width: 100%; height: 100%; overflow: visible; }
.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: #fff; }
.auth-form { width: 100%; max-width: 392px; }
.auth-form .af-h { font-size: 25px; font-weight: 800; letter-spacing: -.04em; }
.auth-form .af-s { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.auth-form form { margin-top: 26px; display: flex; flex-direction: column; gap: 14px; }
.auth-form .row-between { display: flex; align-items: center; justify-content: space-between; }
.auth-form .err { background: var(--danger-soft); color: #b42318; border: 1px solid #fecdca; border-radius: 10px; padding: 10px 12px; font-size: 12.5px; font-weight: 600; }
.auth-form .foot { margin-top: 18px; font-size: 13px; color: var(--muted); text-align: center; }
.auth-form .foot a { color: var(--primary-ink); font-weight: 700; }
.auth-mobile-brand { display: none; }
@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
  .auth-form-wrap { align-items: flex-start; padding: 30px 20px 60px; }
  .auth-mobile-brand { display: flex; align-items: center; gap: 9px; margin-bottom: 30px; }
  .auth-mobile-brand .bm { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: #fff; display: grid; place-items: center; font-weight: 800; }
}

/* ---------- 모달 · 토스트 ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(16,24,40,.44); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .14s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; max-height: 90vh; display: flex; flex-direction: column; animation: pop .16s ease-out; }
.modal.wide { max-width: 760px; }
.modal.xwide { max-width: 980px; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 20px 14px; }
.modal-h h3 { font-size: 17px; font-weight: 800; letter-spacing: -.03em; flex: 1; }
.modal-b { padding: 0 20px 6px; overflow: auto; }
.modal-f { padding: 16px 20px 20px; display: flex; gap: 8px; justify-content: flex-end; }
@media (max-width: 640px) {
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 20px 20px 0 0; max-height: 92vh; }
  .modal-f .btn { flex: 1; }
}
.toast-root { position: fixed; z-index: 200; left: 50%; bottom: 26px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #101828; color: #fff; border-radius: 11px; padding: 11px 16px; font-size: 13px; font-weight: 600;
  box-shadow: var(--shadow-md); display: flex; align-items: center; gap: 8px; animation: toastIn .2s ease-out; max-width: 90vw;
}
.toast.ok { background: #05603a; }
.toast.err { background: #b42318; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } }

/* ---------- 탭 ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: transparent; padding: 11px 14px 12px; font-size: 13.5px; font-weight: 650; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button:hover { color: var(--ink-2); }
.tabs button.active { color: var(--primary-ink); border-bottom-color: var(--primary); }
.tabs .count { display: inline-block; margin-left: 5px; font-size: 11px; color: var(--muted-2); }

/* ---------- 칸반 ---------- */
.kanban { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: start; }
.kcol { background: #eef1f7; border-radius: 14px; padding: 10px; min-height: 160px; }
.kcol-h { display: flex; align-items: center; gap: 7px; padding: 4px 6px 10px; font-size: 12.5px; font-weight: 750; color: var(--ink-2); }
.kcol-h .dot { width: 8px; height: 8px; border-radius: 50%; }
.kcol-h .n { margin-left: auto; font-size: 11.5px; color: var(--muted); background: #fff; border-radius: 6px; padding: 1px 6px; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px; margin-bottom: 8px; box-shadow: var(--shadow-xs); cursor: pointer; transition: border-color .15s, transform .1s; }
.kcard:hover { border-color: var(--line-2); transform: translateY(-1px); }
.kcard .kc-t { font-size: 12.5px; font-weight: 750; line-height: 1.35; }
.kcard .kc-c { font-size: 11.5px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kcard .kc-d { font-size: 11.5px; color: var(--ink-2); margin-top: 7px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 900px) { .kanban { grid-template-columns: 1fr; gap: 10px; } .kcol { min-height: 0; } }

/* ---------- 고객사 카드 ---------- */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(296px, 1fr)); gap: 14px; }
.client-card { background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 17px; box-shadow: var(--shadow-xs); display: flex; flex-direction: column; gap: 12px; }
.client-card .cc-h { display: flex; align-items: center; gap: 11px; }
.client-card .cc-av { width: 40px; height: 40px; border-radius: 12px; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; font-weight: 800; font-size: 15px; flex: none; }
.client-card .cc-n { font-size: 15px; font-weight: 800; letter-spacing: -.03em; }
.client-card .cc-m { font-size: 12px; color: var(--muted); margin-top: 1px; }
.client-card .cc-info { font-size: 12.5px; color: var(--ink-2); display: flex; flex-direction: column; gap: 4px; }
.client-card .cc-info div { display: flex; gap: 7px; align-items: flex-start; }
.client-card .cc-info svg { width: 14px; height: 14px; color: var(--muted-2); flex: none; margin-top: 2px; }
.client-card .cc-foot { display: flex; gap: 6px; align-items: center; padding-top: 10px; border-top: 1px dashed var(--line); flex-wrap: wrap; }
.portal-pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: var(--ok); white-space: nowrap; flex: none; }
.portal-pill svg { width: 14px; height: 14px; }

/* ---------- 설정 ---------- */
.settings-grid { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 84px; }
.settings-nav a { padding: 9px 12px; border-radius: 9px; font-size: 13px; font-weight: 650; color: var(--muted); }
.settings-nav a:hover { background: rgba(16,24,40,.04); color: var(--ink-2); }
.settings-nav a.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-xs); border: 1px solid var(--line); }
.settings-sections { display: flex; flex-direction: column; gap: 16px; }
.brand-preview { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 12px; border: 1px dashed var(--line-2); background: var(--surface-2); }
.brand-preview .bp-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; overflow: hidden; }
.brand-preview .bp-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.upload-box { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px dashed var(--line-2); border-radius: 12px; background: #fcfcfd; }
.upload-box .preview { width: 58px; height: 58px; border-radius: 10px; border: 1px solid var(--line); background: #fff; display: grid; place-items: center; overflow: hidden; color: var(--muted-2); }
.upload-box .preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.color-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line-2); cursor: pointer; }
.swatch.on { box-shadow: 0 0 0 2px var(--ink); }
@media (max-width: 900px) { .settings-grid { grid-template-columns: 1fr; } .settings-nav { position: static; flex-direction: row; overflow-x: auto; } }

/* ---------- 포털 ---------- */
.portal-root { min-height: 100vh; background: var(--bg); }
.portal-header {
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.portal-header .inner { max-width: 1080px; margin: 0 auto; padding: 13px 20px; display: flex; align-items: center; gap: 13px; }
.portal-header .plogo { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; font-weight: 800; overflow: hidden; flex: none; }
.portal-header .plogo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.portal-header .pname { font-size: 15.5px; font-weight: 800; letter-spacing: -.03em; }
.portal-header .pcompany { font-size: 11.5px; color: var(--muted); }
.portal-nav { border-top: 1px solid var(--line); background: #fff; }
.portal-nav .inner { max-width: 1080px; margin: 0 auto; padding: 0 20px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.portal-nav .inner::-webkit-scrollbar { display: none; }
.portal-nav a { padding: 11px 11px; font-size: 12.5px; font-weight: 650; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.portal-nav a.active { color: var(--primary-ink); border-bottom-color: var(--primary); }
.portal-main { max-width: 1080px; margin: 0 auto; padding: 22px 20px 80px; }
.portal-hero {
  border-radius: 18px; padding: 24px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 92%, #000) 0%, color-mix(in srgb, var(--primary) 62%, #0b1533) 60%, #0b1533 100%);
}
.portal-hero::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.14) 1px, transparent 1px); background-size: 20px 20px; opacity: .5; mask-image: linear-gradient(90deg, transparent, #000); }
.portal-hero h1 { font-size: 24px; font-weight: 800; letter-spacing: -.04em; position: relative; z-index: 1; word-break: keep-all; }
.portal-hero p { font-size: 13.5px; color: rgba(255,255,255,.78); margin-top: 6px; position: relative; z-index: 1; }
.portal-hero .ph-row { display: flex; gap: 8px; margin-top: 16px; position: relative; z-index: 1; flex-wrap: nowrap; }
.portal-hero .ph-stat { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); border-radius: 12px; padding: 9px 12px; min-width: 0; flex: 1; backdrop-filter: blur(4px); }
.portal-hero .ph-stat b { display: block; font-size: 19px; font-weight: 800; letter-spacing: -.03em; }
.portal-hero .ph-stat span { display: block; font-size: 10.5px; color: rgba(255,255,255,.72); white-space: nowrap; letter-spacing: -.02em; }
.portal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
@media (max-width: 860px) { .portal-grid { grid-template-columns: 1fr; } }
.portal-doc { display: flex; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid #f0f2f6; cursor: pointer; }
.portal-doc:last-child { border-bottom: 0; }
.portal-doc .pd-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-ink); display: grid; place-items: center; flex: none; }
.portal-doc .pd-ico svg { width: 18px; height: 18px; }
.portal-doc .pd-t { font-size: 13px; font-weight: 700; display: flex; align-items: baseline; gap: 5px; min-width: 0; }
.portal-doc .pd-t .no { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-doc .pd-s { font-size: 11.5px; color: var(--muted); }
.portal-doc .pd-r { margin-left: auto; text-align: right; display: flex; align-items: center; gap: 4px; }
.portal-doc .pd-r svg, .portal-doc .pd-s svg { width: 16px; height: 16px; opacity: .45; }
.portal-doc .pd-amt { font-weight: 750; font-variant-numeric: tabular-nums; font-size: 13px; }
.portal-sec-h { display: flex; align-items: center; gap: 10px; margin: 24px 0 12px; }
.portal-sec-h h2 { font-size: 16px; font-weight: 800; letter-spacing: -.03em; }
.portal-sec-h .spacer { flex: 1; }
.portal-timeline { display: flex; flex-direction: column; gap: 0; }
.pt-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.pt-item:last-child { border-bottom: 0; }
.pt-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; flex: none; }
.pt-main { flex: 1; min-width: 0; }
.pt-t { font-size: 13px; font-weight: 700; }
.pt-s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pt-r { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* 문서 상세(모달) */
.doc-sheet { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.doc-sheet .sheet-scroll { overflow-x: auto; }
.doc-sheet-h { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.doc-sheet table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: 12.5px; }
.doc-sheet th, .doc-sheet td { padding: 8px 10px; border-bottom: 1px solid #f0f2f6; text-align: left; }
.doc-sheet th { color: var(--muted); font-size: 11px; font-weight: 700; background: #fcfcfd; }
.doc-sheet td.r, .doc-sheet th.r { text-align: right; font-variant-numeric: tabular-nums; }

/* AS 이력 카드 (포털) */
.as-hist { display: grid; gap: 10px; padding: 14px 16px; }
@media (min-width: 720px) { .as-hist { grid-template-columns: 1fr 1fr; } }
.as-hist-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: #fff; }
.ah-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.ah-t { font-size: 13.5px; font-weight: 750; letter-spacing: -.02em; }
.ah-s { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }

/* ---------- 인쇄 도우미 ---------- */
.print-frame { width: 100%; height: 72vh; border: 1px solid var(--line); border-radius: 12px; background: #eef1f6; }

/* ---------- 로딩 ---------- */
.boot { min-height: 60vh; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #eef1f6 25%, #f7f9fc 37%, #eef1f6 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- 유틸 ---------- */
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }
.divider-v { width: 1px; height: 22px; background: var(--line); }
.mt0 { margin-top: 0; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs12 { font-size: 12px; } .fs13 { font-size: 13px; }
.pointer { cursor: pointer; }
.mono { font-family: var(--mono); }
