/* 한중 구매대행 관리 시스템 — 공통 디자인 시스템
   외부 CDN(Google Fonts 등)을 쓰지 않고 시스템 폰트와 자체 SVG 아이콘만 사용합니다 (중국 접속 환경 고려).
   구성: 1 토큰 · 2 기본 · 3 레이아웃 · 4 컴포넌트 · 5 화면별 · 6 반응형 */

/* ── 1. 토큰 ─────────────────────────────────────────── */
:root {
    --c-navy: #172554;
    --c-primary: #1d4ed8;
    --c-primary-hover: #1e40af;
    --c-primary-50: #eff6ff;
    --c-primary-100: #dbeafe;
    --c-bg: #f4f6fa;
    --c-surface: #ffffff;
    --c-surface-2: #f8fafc;
    --c-border: #e2e8f0;
    --c-border-strong: #cbd5e1;
    --c-text: #1e293b;
    --c-text-2: #334155;
    --c-muted: #64748b;
    --c-danger: #dc2626;
    --c-danger-hover: #b91c1c;
    --c-danger-50: #fef2f2;
    --c-danger-200: #fecaca;
    --c-danger-text: #991b1b;
    --c-success: #15803d;
    --c-success-50: #f0fdf4;
    --c-success-text: #166534;
    --c-warning-50: #fffbeb;
    --c-warning-200: #fde68a;
    --c-warning-text: #92400e;
    --c-info-50: #f0f9ff;
    --c-info-text: #075985;
    --track-purchase: #2563eb;
    --track-logistics: #0d9488;
    --track-settlement: #ea580c;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.12);
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.35);
    --control-h: 38px;
    --sidebar-width: 232px;

    /* 이전 변수명 호환 */
    --color-primary: var(--c-primary);
    --color-primary-light: var(--c-primary);
    --color-bg: var(--c-bg);
    --color-surface: var(--c-surface);
    --color-border: var(--c-border);
    --color-text: var(--c-text);
    --color-text-muted: var(--c-muted);
    --color-danger: var(--c-danger);
    --color-success: var(--c-success);
}

/* Temporary Customer Demo 표시(DEMO_MODE=True에서만 렌더링) */
.demo-banner { background: #fef3c7; color: #78350f; border-bottom: 1px solid #f59e0b; text-align: center;
    font-size: 13px; font-weight: 600; padding: 5px 12px; line-height: 1.4; }

/* ── 2. 기본 ─────────────────────────────────────────── */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo",
                 "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: var(--c-bg);
    color: var(--c-text);
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:is(a, button, input, select, textarea, summary, [tabindex]):focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.icon {
    width: 18px; height: 18px; flex-shrink: 0; vertical-align: -3px;
    fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.icon-sm { width: 15px; height: 15px; vertical-align: -2px; }
.icon-lg { width: 22px; height: 22px; }
.text-muted { color: var(--c-muted); font-size: 13px; }
.nowrap { white-space: nowrap; }

/* 입력 컨트롤 공통 */
.content :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]), select, textarea),
.login-card :is(input[type="text"], input[type="password"]) {
    font: inherit;
    font-size: 14px;
    color: var(--c-text);
    background: var(--c-surface);
    border: 1px solid var(--c-border-strong);
    border-radius: var(--radius);
    padding: 8px 10px;
    min-height: var(--control-h);
}
.content textarea { min-height: 64px; resize: vertical; }
.content :is(input, select, textarea):focus { border-color: var(--c-primary); outline: none; box-shadow: var(--focus-ring); }
.content input[type="file"] { font-size: 13px; max-width: 100%; }
.content input[type="number"] { font-variant-numeric: tabular-nums; }
.content input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--c-primary); }

/* ── 3. 레이아웃 ─────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-width);
    background: var(--c-navy);
    color: #fff;
    flex-shrink: 0;
    padding: 18px 0 24px;
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid rgba(255, 255, 255, 0.12); margin-bottom: 10px; }
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    font-size: 15px; font-weight: 700; line-height: 1.3; word-break: keep-all;
    padding: 0 18px 18px;
}
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px; background: rgba(255, 255, 255, 0.14); flex-shrink: 0;
}
.nav-menu-toggle, .nav-current { display: none; }
.sidebar-nav { display: flex; flex-direction: column; padding: 0 10px; }
.sidebar :is(a, button):focus-visible { box-shadow: 0 0 0 2px #93c5fd; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    color: rgba(255, 255, 255, 0.84);
    padding: 9px 10px;
    border-radius: var(--radius);
    font-size: 14px;
    position: relative;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; text-decoration: none; }
.nav-link.active { background: rgba(255, 255, 255, 0.14); color: #fff; font-weight: 600; }
.nav-link.active::before, .nav-sublink.active::before {
    content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px;
    border-radius: 0 3px 3px 0; background: #93c5fd;
}
.nav-top { margin-bottom: 6px; }
.nav-tree { list-style: none; margin: 0; padding: 0; }
.nav-group { margin: 1px 0; }
.nav-group-toggle {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: none; border: none; cursor: pointer; text-align: left;
    color: rgba(255, 255, 255, 0.84); font-family: inherit; font-size: 14px;
    padding: 9px 10px; border-radius: var(--radius);
}
.nav-group-toggle:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-group.is-current > .nav-group-toggle { color: #fff; font-weight: 600; }
.nav-group-name { flex: 1; min-width: 0; line-height: 1.35; }
.nav-chevron { width: 16px; height: 16px; margin-left: auto; opacity: 0.7; transition: transform 0.15s; }
.nav-group-toggle[aria-expanded="true"] .nav-chevron { transform: rotate(180deg); }
.nav-sub { list-style: none; margin: 2px 0 6px 19px; padding: 0 0 0 10px; border-left: 1px solid rgba(255, 255, 255, 0.16); }
.nav-sub[hidden] { display: none; }
.nav-sublink {
    display: block; position: relative; padding: 7px 10px; border-radius: var(--radius-sm);
    font-size: 13px; line-height: 1.4; color: rgba(255, 255, 255, 0.74);
}
.nav-sublink:hover { background: rgba(255, 255, 255, 0.08); color: #fff; text-decoration: none; }
.nav-sublink.active { background: rgba(255, 255, 255, 0.14); color: #fff; font-weight: 600; }
.nav-sublink.active::before { left: -11px; top: 7px; bottom: 7px; }

.main-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    min-height: 58px;
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    display: flex; align-items: center; justify-content: flex-end;
    gap: 14px;
    padding: 8px 24px;
    position: sticky; top: 0; z-index: 20;
}
.content { padding: 24px 28px 40px; max-width: 1360px; width: 100%; }

.language-switch { display: flex; gap: 2px; margin: 0; padding: 2px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface-2); }
.lang-button {
    padding: 4px 10px; font-size: 12px; font-weight: 600; border-radius: var(--radius-sm);
    border: none; background: transparent; color: var(--c-muted); cursor: pointer; font-family: inherit;
}
.lang-button.active { background: var(--c-surface); color: var(--c-primary); box-shadow: var(--shadow-sm); }
.topbar-user { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.topbar-vendor { color: var(--c-muted); font-size: 13px; }
.badge {
    display: inline-block; background: var(--c-primary-50); color: var(--c-primary);
    font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
}
.logout-form { margin: 0; }
.link-button {
    display: inline-flex; align-items: center; gap: 6px;
    background: none; border: none; cursor: pointer; font-family: inherit;
    color: var(--c-muted); font-size: 14px; padding: 6px 8px; border-radius: var(--radius-sm);
}
.link-button:hover { color: var(--c-danger); background: var(--c-danger-50); }

/* ── 4. 컴포넌트 ─────────────────────────────────────── */

/* 페이지 헤더 / 위치 */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--c-muted); margin: 0 0 10px; }
.breadcrumbs a { color: var(--c-muted); }
.breadcrumbs a:hover { color: var(--c-primary); }
.breadcrumbs [aria-current] { color: var(--c-text); font-weight: 600; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-title { display: flex; align-items: center; gap: 10px; font-size: 21px; font-weight: 700; margin: 0 0 16px; line-height: 1.35; }
.page-header .page-title { margin: 0; }
.title-icon {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 34px; height: 34px; border-radius: 9px; background: var(--c-primary-50); color: var(--c-primary);
}
.header-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-intro { color: var(--c-muted); font-size: 13px; margin: -8px 0 16px; line-height: 1.6; }
.flow-legend { font-size: 12px; color: var(--c-muted); margin: -6px 0 14px; line-height: 1.6; }

/* 카드 */
.panel, .form-panel, .danger-zone {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px;
}
.panel + .panel, .panel + .danger-zone, .panel + section, .alert + .panel, .alert + .form-panel,
.form-panel + .panel, .stat-grid + .panel { margin-top: 16px; }
.panel-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; font-weight: 700; margin: 0 0 14px; }
.panel-title .icon { color: var(--c-muted); }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.panel-header .panel-title { margin: 0; }
.panel-attention { border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12); }
.section-title { font-size: 14px; font-weight: 700; margin: 22px 0 10px; color: var(--c-text-2); }
.sub-title { font-size: 14px; margin: 16px 0 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* 버튼 */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: var(--control-h); padding: 0 15px;
    border-radius: var(--radius); border: 1px solid transparent;
    font-family: inherit; font-size: 14px; font-weight: 600; line-height: 1.2;
    cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary:hover, .btn-secondary:hover, .btn-danger:hover { text-decoration: none; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-hover); }
.btn-secondary { background: var(--c-surface); color: var(--c-text-2); border-color: var(--c-border-strong); }
.btn-secondary:hover { background: var(--c-surface-2); border-color: #94a3b8; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-danger:hover { background: var(--c-danger-hover); }
.btn-small { min-height: 30px; padding: 0 11px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-inline { width: auto; }
:is(.btn-primary, .btn-danger, .btn-secondary):disabled { opacity: 0.45; cursor: not-allowed; }
.form-actions { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.next-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* 배지 */
.status-pill {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap;
    background: #f1f5f9; color: var(--c-text-2);
}
.status-requested { background: #e0e7ff; color: #3730a3; }
.status-quoted, .status-submitted { background: #fef3c7; color: #92400e; }
.status-approved, .status-used, .status-partially_approved { background: var(--c-primary-100); color: #1e40af; }
.status-purchasing, .status-confirmed, .status-partially_approved_closed { background: #e0e7ff; color: #3730a3; }
.status-completed { background: #dcfce7; color: var(--c-success-text); }
.status-cancelled, .status-rejected { background: #fee2e2; color: var(--c-danger-text); }
.status-registered { background: #f1f5f9; color: var(--c-text-2); }
.logistics-china_shipping { background: #f1f5f9; color: var(--c-text-2); }
.logistics-warehoused { background: #fef3c7; color: #92400e; }
.logistics-inspected { background: #e0e7ff; color: #3730a3; }
.logistics-intl_shipping { background: var(--c-primary-100); color: #1e40af; }
.logistics-received { background: #dcfce7; color: var(--c-success-text); }
.hint-pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #fef3c7; color: #92400e; white-space: nowrap; }
.urgent-pill { background: #fee2e2; color: var(--c-danger-text); margin-left: 6px; vertical-align: middle; }
.direction-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.direction-deposit { background: #dcfce7; color: var(--c-success-text); }
.direction-withdrawal { background: #fee2e2; color: var(--c-danger-text); }

/* 알림 메시지 */
.alert {
    display: block; padding: 11px 14px; border-radius: var(--radius); margin-bottom: 14px;
    font-size: 14px; border: 1px solid transparent; border-left-width: 4px;
}
.alert-error, .alert-danger { background: var(--c-danger-50); color: var(--c-danger-text); border-color: var(--c-danger-200); border-left-color: var(--c-danger); }
.alert-success { background: var(--c-success-50); color: var(--c-success-text); border-color: #bbf7d0; border-left-color: var(--c-success); }
.alert-info { background: var(--c-info-50); color: var(--c-info-text); border-color: #bae6fd; border-left-color: #0284c7; }
.alert-warning { background: var(--c-warning-50); color: var(--c-warning-text); border-color: var(--c-warning-200); border-left-color: #f59e0b; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert p { margin: 4px 0 0; }
.alert p:first-child { margin-top: 0; }
.alert .errorlist { color: inherit; font-size: 14px; }

/* 폼 */
.form-legend { font-size: 12px; color: var(--c-muted); margin: 0 0 14px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-field, .form-group { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.form-group { margin-bottom: 14px; }
.form-field-wide { grid-column: 1 / -1; }
.form-field label, .form-group label, .field-label { color: var(--c-text-2); font-size: 13px; font-weight: 600; }
.form-field :is(input, select, textarea), .form-group :is(input:not([type="checkbox"]), select, textarea) { width: 100%; }
.form-help { color: var(--c-muted); font-size: 12px; line-height: 1.5; }
.form-help ul { margin: 4px 0 0; padding-left: 18px; }
.field-error, .errorlist { color: var(--c-danger); font-size: 12px; }
.errorlist { list-style: none; margin: 2px 0 0; padding: 0; }
.required-mark { color: var(--c-danger); margin-left: 2px; }
.form-field.has-error :is(input, select, textarea) { border-color: var(--c-danger); }
.check-label { display: flex !important; align-items: center; gap: 8px; color: var(--c-text) !important; font-weight: 500 !important; font-size: 14px !important; cursor: pointer; }
.check-label input[type="checkbox"] { width: 16px; margin: 0; }
.item-card { border: 1px solid var(--c-border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; background: var(--c-surface-2); }
.item-card-title { font-size: 13px; font-weight: 700; margin: 0 0 10px; color: var(--c-text-2); }

/* 필터 */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filter-bar label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--c-muted); }
.filter-bar input[type="text"] { flex: 1 1 220px; max-width: 320px; }
.vendor-filter { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 14px; color: var(--c-text-2); }

/* 테이블 */
/* position: 셀 안의 .sr-only(absolute)가 스크롤 영역 밖 문서 폭을 늘리지 않도록 기준 박스로 둔다. */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.data-table thead th { background: var(--c-surface-2); color: var(--c-muted); font-weight: 600; font-size: 12px; white-space: nowrap; border-bottom-color: var(--c-border-strong); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.data-table .nowrap { white-space: nowrap; }
.data-table td.row-title { max-width: 340px; }
.clickable-row { cursor: pointer; }
.clickable-row:hover td { background: #f8fafc; }
.row-link { font-weight: 600; white-space: nowrap; }
.cell-truncate { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.formset-table td { padding: 6px 4px; }
.formset-table input[type="number"] { min-width: 80px; }
.table-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.table-actions a {
    display: inline-flex; align-items: center; min-height: 26px; padding: 0 9px;
    border: 1px solid var(--c-border-strong); border-radius: var(--radius-sm);
    font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--c-surface); color: var(--c-text-2);
}
.table-actions a:hover { background: var(--c-primary-50); border-color: var(--c-primary); color: var(--c-primary); text-decoration: none; }
.qty-line { display: block; font-size: 12px; color: var(--c-muted); }
.pagination { display: flex; gap: 12px; align-items: center; justify-content: flex-end; margin-top: 14px; font-size: 14px; }
.empty-state { color: var(--c-muted); font-size: 14px; padding: 22px 8px; text-align: center; margin: 0; }
.empty-state-hint { display: block; margin-top: 4px; font-size: 13px; }

/* 상세 정보 */
.detail-grid { display: grid; grid-template-columns: 140px minmax(0, 1fr); row-gap: 10px; column-gap: 14px; font-size: 14px; margin: 0 0 18px; }
.detail-grid dt { color: var(--c-muted); }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.info-grid .detail-grid { margin: 0; }

/* 인라인 결정 폼 */
.inline-review-form { display: flex; gap: 8px; align-items: flex-start; margin: 0; }
.inline-review-form textarea { flex: 1; min-height: 38px !important; font-size: 13px !important; padding: 6px 8px !important; }
.decision-forms { display: flex; flex-wrap: wrap; gap: 10px 20px; padding: 4px 0; }
.decision-forms .inline-review-form { align-items: center; flex-wrap: wrap; }
.decision-forms label { font-size: 12px; font-weight: 600; color: var(--c-muted); white-space: nowrap; }
.decision-forms input[type="number"] { width: 84px; }
.decision-forms input[type="text"] { min-width: 170px; }

/* 위험 작업 */
.danger-zone { border-color: var(--c-danger-200); margin-top: 16px; }
.danger-zone .panel-title { color: var(--c-danger-text); }
.danger-zone .panel-title .icon { color: var(--c-danger); }
.action-disclosure { border-top: 1px solid var(--c-border); padding: 12px 0; }
.action-disclosure:first-of-type { border-top: none; }
.action-disclosure > summary { cursor: pointer; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.action-disclosure > summary::-webkit-details-marker { display: none; }
.action-disclosure > summary::before { content: "▸"; color: var(--c-muted); transition: transform 0.15s; }
.action-disclosure[open] > summary::before { transform: rotate(90deg); }
.action-disclosure.danger > summary { color: var(--c-danger-text); }
.action-disclosure[open] > summary { margin-bottom: 10px; }
.action-disclosure form { max-width: 560px; }
.consequence { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--c-text-2); margin: 0 0 10px; }
.consequence .icon { color: var(--c-danger); margin-top: 1px; }
.consequence-positive .icon { color: var(--c-primary); }
/* 경고가 아닌 안내(info 아이콘)는 위험색 대신 중립 안내색으로 표시한다. */
.consequence .icon:has(use[href="#i-info"]) { color: var(--c-primary); }

/* 통계 카드 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card {
    position: relative; background: var(--c-surface); border: 1px solid var(--c-border);
    border-left: 4px solid var(--c-border-strong); border-radius: var(--radius-lg);
    padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.stat-card .stat-icon { position: absolute; top: 14px; right: 14px; color: var(--c-muted); opacity: 0.7; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--c-muted); margin-bottom: 6px; padding-right: 26px; }
.stat-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card.accent-blue { border-left-color: #3b82f6; }
.stat-card.accent-green { border-left-color: #16a34a; }
.stat-card.accent-indigo { border-left-color: #6366f1; }
.stat-card.accent-amber { border-left-color: #f59e0b; }
.stat-card.accent-teal { border-left-color: #14b8a6; }
.stat-card.accent-rose { border-left-color: #e11d48; }
.stat-card.highlight { background: var(--c-primary-50); box-shadow: 0 0 0 1px var(--c-primary) inset; }

/* 처리 필요 카드 (대시보드) */
.todo-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 18px; }
.todo-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg);
    padding: 14px 16px; color: var(--c-text); box-shadow: var(--shadow-sm);
}
a.todo-card:hover { border-color: var(--c-primary); text-decoration: none; background: var(--c-primary-50); }
.todo-icon { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 10px; background: var(--c-primary-50); color: var(--c-primary); flex-shrink: 0; }
.todo-card.is-attention .todo-icon { background: #fef3c7; color: #b45309; }
.todo-body { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.todo-label { font-size: 13px; color: var(--c-muted); font-weight: 600; }
.todo-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.todo-go { color: var(--c-muted); }

/* 차트 */
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; align-items: stretch; }
.chart-row .panel + .panel { margin-top: 0; }
.chart-panel { display: flex; flex-direction: column; }
.chart-canvas-wrap { position: relative; height: 220px; width: 100%; }

/* ── 주문 진행 (아이콘 스텝) ── */
.progress-steps { list-style: none; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); }
.progress-step { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 4px; min-width: 0; }
.progress-step::before {
    content: ""; position: absolute; top: 21px; left: calc(-50% + 26px); right: calc(50% + 26px);
    height: 2px; background: var(--c-border-strong);
}
.progress-step:first-child::before { display: none; }
.progress-step.is-done::before, .progress-step.is-active::before, .progress-step.is-current::before { background: var(--c-primary); }
.step-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 50%;
    border: 2px solid var(--c-border-strong); background: var(--c-surface); color: #94a3b8;
    position: relative; z-index: 1;
}
.step-icon .icon { width: 20px; height: 20px; }
.step-check {
    position: absolute; right: -3px; bottom: -3px; width: 17px; height: 17px; border-radius: 50%;
    background: var(--c-success); color: #fff; border: 2px solid var(--c-surface);
    display: inline-flex; align-items: center; justify-content: center;
}
.step-check .icon { width: 10px; height: 10px; stroke-width: 3; }
.step-text { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.step-label { margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--c-text-2); line-height: 1.3; word-break: keep-all; }
.step-caption { margin-top: 2px; font-size: 11px; color: var(--c-muted); line-height: 1.35; word-break: keep-all; }
.progress-step.is-done .step-icon { border-color: var(--c-primary); background: var(--c-primary-50); color: var(--c-primary); }
.progress-step.is-active .step-icon { border-color: var(--track-logistics); background: #f0fdfa; color: var(--track-logistics); }
.progress-step.is-current .step-icon { border-color: var(--c-primary); background: var(--c-primary); color: #fff; box-shadow: 0 0 0 5px var(--c-primary-100); }
.progress-step.is-current .step-label { color: var(--c-primary); }
.progress-step.is-current .step-caption { color: var(--c-primary); font-weight: 600; }
.progress-step.is-upcoming .step-icon { border-style: dashed; }
.progress-step.is-none .step-icon { background: var(--c-surface-2); border-style: dashed; color: #cbd5e1; }
.progress-step.is-none .step-label { color: #94a3b8; }
.progress-muted .progress-step .step-icon { filter: grayscale(0.6); opacity: 0.75; }

.status-guide { margin: 18px 0 0; padding: 12px 14px; border-radius: var(--radius); background: var(--c-surface-2); border: 1px solid var(--c-border); font-size: 14px; line-height: 1.6; display: flex; gap: 10px; align-items: flex-start; }
.status-guide .icon { color: var(--c-primary); margin-top: 2px; }
.status-guide strong { display: block; }

.track-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.track { display: flex; align-items: center; gap: 10px; border: 1px solid var(--c-border); border-radius: var(--radius); padding: 8px 10px; background: var(--c-surface); min-width: 0; }
.track-label { flex-shrink: 0; font-size: 12px; font-weight: 700; color: #fff; padding: 3px 9px; border-radius: var(--radius-sm); }
.track-purchase .track-label { background: var(--track-purchase); }
.track-logistics .track-label { background: var(--track-logistics); }
.track-settlement .track-label { background: var(--track-settlement); }
.track-value { font-size: 13px; color: var(--c-text-2); min-width: 0; overflow-wrap: anywhere; }
.track-value .status-pill { margin: 1px 4px 1px 0; }

/* 주문 헤더 */
.order-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--c-muted); margin: -10px 0 16px; }
.order-meta span { display: inline-flex; align-items: center; gap: 5px; }

/* 견적 카드 */
.quote-card { border: 1px solid var(--c-border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.quote-card.needs-review { border-color: #f59e0b; background: #fffdf5; }
.quote-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.quote-cost-grid { grid-template-columns: 140px minmax(0, 1fr) 140px minmax(0, 1fr); }

/* 댓글 */
.comment-list { list-style: none; margin: 0 0 16px; padding: 0; }
.comment-item { padding: 12px 0; border-bottom: 1px solid var(--c-border); }
.comment-item:last-child { border-bottom: none; }
.comment-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; flex-wrap: wrap; }
.comment-content { margin: 0; font-size: 14px; white-space: pre-wrap; }
.comment-form { border-top: 1px solid var(--c-border); padding-top: 14px; }
.comment-form textarea { width: 100%; margin-bottom: 8px; }
.comment-form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* 알림 목록 */
.notification-list { list-style: none; margin: 0; padding: 0; }
.notification-item { border-bottom: 1px solid var(--c-border); }
.notification-item:last-child { border-bottom: none; }
.notification-item.unread { background: var(--c-primary-50); }
.notification-link {
    width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px;
    background: none; border: none; cursor: pointer; padding: 12px 8px; text-align: left; font: inherit; color: inherit;
}
.notification-main { display: flex; align-items: flex-start; gap: 10px; min-width: 0; }
.notification-dot { width: 8px; height: 8px; border-radius: 50%; background: transparent; margin-top: 7px; flex-shrink: 0; }
.unread .notification-dot { background: var(--c-primary); }
.notification-message { color: var(--c-text); }
.notification-order { display: block; font-size: 12px; color: var(--c-muted); }
.notification-meta { color: var(--c-muted); font-size: 12px; white-space: nowrap; }

/* 알림 미리보기 (상단 종) */
.notif-wrap { position: relative; }
.notification-bell {
    position: relative; display: inline-flex; align-items: center; gap: 6px;
    font-size: 14px; color: var(--c-text-2); padding: 7px 10px; border-radius: var(--radius);
    background: none; border: 1px solid transparent; cursor: pointer; font-family: inherit;
}
.notification-bell:hover, .notification-bell[aria-expanded="true"], .notification-bell[aria-current="page"] { background: var(--c-surface-2); border-color: var(--c-border); text-decoration: none; }
.notification-badge {
    display: inline-block; min-width: 18px; text-align: center;
    background: var(--c-danger); color: #fff; font-size: 11px; font-weight: 700;
    padding: 1px 6px; border-radius: 999px;
}
.notif-panel {
    position: absolute; right: 0; top: calc(100% + 8px); width: 380px; max-width: calc(100vw - 24px);
    background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md); z-index: 50; overflow: hidden;
}
.notif-panel[hidden] { display: none; }
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--c-border); }
.notif-head strong { font-size: 14px; }
.notif-body { max-height: 360px; overflow-y: auto; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item { border-bottom: 1px solid var(--c-border); }
.notif-item:last-child { border-bottom: none; }
.notif-item form { margin: 0; }
.notif-open {
    display: flex; gap: 10px; width: 100%; text-align: left; padding: 11px 14px;
    background: none; border: none; cursor: pointer; font: inherit; color: inherit;
}
.notif-open:hover, .notif-open:focus-visible { background: var(--c-surface-2); }
.notif-item.unread .notif-open { background: var(--c-primary-50); }
.notif-item.unread .notif-open:hover { background: var(--c-primary-100); }
.notif-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.notif-message { font-size: 13px; color: var(--c-text); line-height: 1.45; }
.notif-sub { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--c-muted); }
.notif-state { font-size: 11px; font-weight: 700; color: var(--c-primary); }
.notif-status { padding: 16px 14px; font-size: 13px; color: var(--c-muted); text-align: center; }
.notif-foot { padding: 10px 14px; border-top: 1px solid var(--c-border); background: var(--c-surface-2); text-align: center; font-size: 13px; }

/* ── 5. 화면별 ───────────────────────────────────────── */

/* 로그인 */
.login-page {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 16px; padding: 16px; background: linear-gradient(160deg, #1e3a8a 0%, #0f172a 100%);
}
.login-language-switch { position: fixed; top: 20px; right: 20px; background: rgba(255, 255, 255, 0.92); }
.login-card {
    background: var(--c-surface); border-radius: 14px; padding: 36px 32px;
    width: 360px; max-width: 100%; box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
}
.login-title { display: flex; align-items: center; gap: 10px; font-size: 18px; margin: 0 0 4px; color: var(--c-navy); }
.login-title .brand-mark { background: var(--c-primary-50); color: var(--c-primary); }
.login-subtitle { font-size: 13px; color: var(--c-muted); margin: 0 0 20px; }
.login-card .field-label { display: block; margin: 12px 0 6px; }
.login-card input[type="text"], .login-card input[type="password"] { width: 100%; }
.login-card .btn-primary { margin-top: 20px; }

/* 오류 페이지 */
.error-page { max-width: 560px; }
.error-standalone { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }

/* 계정 · 변경 이력 */
.topbar-user-link { display: inline-flex; align-items: center; gap: 6px; color: var(--c-text); padding: 4px 8px; border-radius: var(--radius-sm); }
.topbar-user-link:hover, .topbar-user-link.active { background: var(--c-surface-2); text-decoration: none; }
.login-help { margin: 14px 0 0; font-size: 12px; color: var(--c-muted); text-align: center; }
.history-disclosure > summary { cursor: pointer; list-style: none; }
.history-disclosure > summary::-webkit-details-marker { display: none; }
.history-disclosure > summary .panel-title::after { content: "▸"; color: var(--c-muted); margin-left: auto; transition: transform 0.15s; }
.history-disclosure[open] > summary .panel-title::after { transform: rotate(90deg); }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item { border-left: 2px solid var(--c-border-strong); padding: 0 0 14px 14px; margin-left: 4px; position: relative; }
.history-item::before { content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--c-surface); border: 2px solid var(--c-primary); }
.history-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 6px; }
.history-table { font-size: 13px; max-width: 760px; }
.history-table th, .history-table td { padding: 6px 8px; }
.history-reason { margin: 6px 0 0; font-size: 13px; color: var(--c-text-2); }

/* 로그인 밖 계정 화면(비밀번호 재설정) — 로그인 카드와 같은 형식 */
.auth-card { width: 420px; }
.auth-card .login-title { font-size: 17px; }
.auth-card .form-field { margin: 0; }
.auth-card :is(input[type="email"], input[type="password"]) { width: 100%; }
.auth-card .alert { margin: 0 0 12px; }
.auth-card .errorlist, .auth-card .form-help { font-size: 12px; }
.auth-back { display: block; margin-top: 16px; font-size: 13px; text-align: center; }

/* 댓글 수정·삭제는 필요할 때만 펼친다 */
.comment-manage { margin-top: 6px; font-size: 13px; }
.comment-manage > summary { cursor: pointer; color: var(--c-muted); display: inline-block; padding: 2px 0; }
.comment-manage[open] > summary { color: var(--c-text-2); margin-bottom: 6px; }
.comment-manage form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 8px; margin: 0 0 8px; padding: 10px; background: var(--c-surface-2); border-radius: var(--radius-sm); }
.comment-manage label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 260px; color: var(--c-text-2); }
.comment-manage textarea, .comment-manage input[type="text"] { width: 100%; }
.comment-edited { font-size: 12px; margin-left: 2px; }

/* 주문 담당자 */
.assignee-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 12px; margin: 0 0 10px; }
.assignee-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--c-text-2); flex: 1 1 220px; min-width: 0; }
.assignee-form select, .assignee-form input[type="text"] { width: 100%; }

/* 현지 구매완료 확인 */
.local-purchase-state { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.local-purchase-note { margin: 0 0 12px; }
a.stat-card-link { color: inherit; text-decoration: none; }
a.stat-card-link:hover { border-color: var(--c-primary); text-decoration: none; }
.track-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex-basis: 100%; margin-top: 4px; font-size: 12px; color: var(--c-text-2); word-break: keep-all; }

/* 거래처 관리 */
.summary-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.summary-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; background: var(--c-surface); border: 1px solid var(--c-border); font-size: 13px; color: var(--c-text-2); }
.summary-chip strong { font-variant-numeric: tabular-nums; }
.vendor-table tbody tr[data-vendor-row] td { vertical-align: middle; }
.vendor-manage-row > td { background: var(--c-surface-2); border-bottom: 1px solid var(--c-border-strong); }
.vendor-manage { max-width: 640px; padding: 6px 2px; }
.filter-bar input[type="search"] { flex: 1 1 220px; max-width: 320px; }

/* 원장 */
.ledger-table { min-width: 1080px; }
.ledger-actions { min-width: 250px; }
/* 넓은 화면에서 표가 가로로 넘쳐도 '처리' 열은 오른쪽에 고정해 스크롤 없이 보이게 한다. */
@media (min-width: 1024px) {
    .ledger-table td.ledger-actions,
    .ledger-table:has(td.ledger-actions) thead th:last-child {
        position: sticky; right: 0; z-index: 1;
        box-shadow: inset 1px 0 0 var(--c-border);
    }
    .ledger-table td.ledger-actions { background: var(--c-surface); }
}
.ledger-actions .inline-review-form + .inline-review-form,
.ledger-actions .inline-review-form + details,
.ledger-actions .text-muted + .inline-review-form { margin-top: 6px; }
.ledger-actions details > summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--c-danger-text); margin-top: 6px; }

/* ── 6. 반응형 ───────────────────────────────────────── */
@media (max-width: 1100px) {
    .progress-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: 18px; }
    .progress-step:nth-child(4n + 1)::before { display: none; }
    .quote-cost-grid { grid-template-columns: 140px minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; padding: 0; position: sticky; top: 0; z-index: 30; height: auto; overflow: visible; align-self: stretch; }
    .sidebar-head { padding: 8px 12px; margin: 0; border-bottom: none; }
    .sidebar-brand { padding: 0; font-size: 14px; min-width: 0; }
    .brand-mark { width: 24px; height: 24px; }
    .nav-menu-toggle {
        display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
        background: rgba(255, 255, 255, 0.12); color: #fff; border: 1px solid rgba(255, 255, 255, 0.24);
        border-radius: var(--radius); padding: 6px 10px; font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
    }
    .nav-current { display: block; margin: 0; padding: 0 14px 8px; font-size: 12px; color: rgba(255, 255, 255, 0.78); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .sidebar-nav { display: none; padding: 4px 10px 12px; max-height: calc(100vh - 96px); overflow-y: auto; border-top: 1px solid rgba(255, 255, 255, 0.12); }
    .sidebar.is-menu-open .sidebar-nav { display: flex; }
    .nav-group-toggle, .nav-link { padding: 11px 10px; }
    .nav-sublink { padding: 10px 10px; font-size: 14px; }
    .topbar { position: static; z-index: 40; min-height: 0; flex-wrap: wrap; padding: 8px 12px; gap: 8px 10px; justify-content: flex-start; }
    .topbar-user { flex-wrap: wrap; }
    .content { padding: 14px 12px 32px; }
    .page-title { font-size: 18px; }
    .title-icon { width: 30px; height: 30px; }
    .panel, .form-panel, .danger-zone { padding: 14px; }
    .form-grid, .info-grid, .track-row { grid-template-columns: 1fr; }
    .detail-grid, .quote-cost-grid { grid-template-columns: 110px minmax(0, 1fr); }
    .filter-bar > * { flex: 1 1 140px; }
    .filter-bar input[type="text"], .filter-bar input[type="search"] { max-width: none; }
    .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrap .data-table { display: table; }
    .data-table th, .data-table td { white-space: nowrap; }
    .vendor-manage-row > td { white-space: normal; }
    .vendor-manage { min-width: 280px; }
    .inline-review-form { flex-wrap: wrap; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .stat-value { font-size: 18px; }
    .todo-grid { grid-template-columns: 1fr; }
    .chart-row { grid-template-columns: 1fr; }
    .chart-canvas-wrap { height: 200px; }
    .notification-link { flex-direction: column; align-items: flex-start; gap: 4px; }
    .notif-panel { position: fixed; left: 8px; right: 8px; top: 64px; width: auto; max-width: none; }
    .notif-body { max-height: 60vh; }
}
@media (max-width: 640px) {
    .progress-steps { grid-template-columns: 1fr; row-gap: 0; }
    .progress-step { flex-direction: row; align-items: center; text-align: left; gap: 12px; padding: 6px 0 6px 0; }
    .progress-step::before { top: -14px; bottom: auto; left: 21px; right: auto; width: 2px; height: 28px; }
    .progress-step:nth-child(4n + 1)::before { display: block; }
    .progress-step:first-child::before { display: none; }
    .step-icon { width: 40px; height: 40px; }
    .step-text { align-items: flex-start; }
    .step-label { margin-top: 0; }
    .login-card { padding: 28px 20px; }
}
