/* ───────────────────────── QTReq 공통 스타일 ─────────────────────────
   DevExpress Fluent 테마 위에 얹는 앱 고유 스타일. 색은 아래 변수로만 바꾼다. */
:root {
    --qt-primary: #1d4ed8;
    --qt-primary-dark: #1e3a8a;
    --qt-primary-soft: #eff4ff;
    --qt-bg: #f4f6fa;
    --qt-surface: #ffffff;
    --qt-border: #e3e7ef;
    --qt-text: #1f2937;
    --qt-muted: #6b7280;
    --qt-danger: #c62828;
    --qt-radius: 10px;
    --qt-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
    --qt-font: "Pretendard", "Malgun Gothic", "맑은 고딕", "Segoe UI", system-ui, sans-serif;
}

html, body {
    margin: 0;
    background: var(--qt-bg);
    color: var(--qt-text);
    font-family: var(--qt-font);
    font-size: 14px;
}

* { box-sizing: border-box; }
h1:focus { outline: none; }
a { color: var(--qt-primary); }
code { font-family: Consolas, "D2Coding", "Malgun Gothic", "맑은 고딕", monospace; font-size: .92em; background: #f1f3f7; padding: 1px 5px; border-radius: 4px; }
kbd { display: inline-block; padding: 0 5px; border: 1px solid #cfd5df; border-bottom-width: 2px; border-radius: 4px; background: #fff; font-family: inherit; font-size: .85em; line-height: 1.5; }

.muted { color: var(--qt-muted); }
.small { font-size: 12.5px; }
.w-100 { width: 100%; }
.mt-2 { margin-top: .5rem; }
.mb-1 { margin-bottom: .25rem; }
.narrow { max-width: 760px; }
.inline-form { display: inline; margin: 0; }
.link-button { background: none; border: none; padding: 0; color: var(--qt-primary); cursor: pointer; font: inherit; }
.link-button:hover { text-decoration: underline; }
.link-danger { color: var(--qt-danger); }

/* ───────── 앱 껍데기 ───────── */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: 28px;
    height: 56px; padding: 0 24px;
    background: var(--qt-primary-dark); color: #fff;
    box-shadow: 0 2px 6px rgba(15, 23, 42, .18);
}
.app-brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; white-space: nowrap; }
/* MES 로고는 남색이라 어두운 헤더 위에서는 흰 바탕 타일에 올린다 */
.app-brand img { width: 32px; height: 32px; padding: 1px; border-radius: 7px; background: #fff; }
.app-brand-name { font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.app-brand-sub { font-size: 13px; opacity: .75; padding-left: 8px; border-left: 1px solid rgba(255,255,255,.3); }

.app-nav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; }
.app-nav-link {
    color: rgba(255,255,255,.82); text-decoration: none; padding: 8px 14px; border-radius: 8px; white-space: nowrap; font-weight: 500;
}
.app-nav-link:hover { background: rgba(255,255,255,.1); color: #fff; }
.app-nav-link.active { background: rgba(255,255,255,.18); color: #fff; }

.app-user { display: flex; align-items: center; gap: 12px; white-space: nowrap; font-size: 13px; }
.app-user-name { font-weight: 600; }
.app-user-link, .app-user .link-button { color: rgba(255,255,255,.8); text-decoration: none; font-size: 13px; }
.app-user-link:hover, .app-user .link-button:hover { color: #fff; text-decoration: underline; }
.app-user-badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.app-user-badge.badge-admin { background: #fbbf24; color: #422006; }
.app-user-badge.badge-company { background: rgba(255,255,255,.2); color: #fff; }

.app-main { flex: 1; width: 100%; max-width: 1480px; margin: 0 auto; padding: 24px; }

.page-message { max-width: 520px; margin: 80px auto; text-align: center; color: var(--qt-muted); }
.page-message h2 { color: var(--qt-text); }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.page-title { margin: 0 0 4px; font-size: 22px; font-weight: 700; }
.page-desc { margin: 0; color: var(--qt-muted); }

.card { background: var(--qt-surface); border: 1px solid var(--qt-border); border-radius: var(--qt-radius); box-shadow: var(--qt-shadow); padding: 20px; }
.card + .card { margin-top: 16px; }
.card-title { margin: 0 0 12px; font-size: 15px; font-weight: 700; }

/* ───────── 배지 ───────── */
.status-badge { display: inline-block; min-width: 52px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; text-align: center; white-space: nowrap; border: 1px solid transparent; }
.status-received   { background: #eef2ff; color: #3730a3; border-color: #c7d2fe; }
.status-reviewing  { background: #fff7e6; color: #9a5b00; border-color: #fcd9a0; }
.status-inprogress { background: #e0f2fe; color: #075985; border-color: #a5d8f7; }
.status-completed  { background: #e8f7ee; color: #166534; border-color: #b4e3c5; }
.status-onhold     { background: #f3f4f6; color: #4b5563; border-color: #d8dbe1; }
.status-rejected   { background: #fdecec; color: #991b1b; border-color: #f5c2c2; }

.mini-badge { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 600; line-height: 18px; vertical-align: middle; }
.mini-badge.badge-admin { background: #fef3c7; color: #92400e; }
.mini-badge.badge-danger { background: #fdecec; color: #991b1b; }
.mini-badge.badge-warning { background: #fff7e6; color: #9a5b00; }
.mini-badge.badge-success { background: #e8f7ee; color: #166534; }
.mini-badge.badge-muted { background: #f3f4f6; color: #6b7280; }

.category-tag { display: inline-block; padding: 1px 8px; border-radius: 4px; background: #f1f3f7; color: #475569; font-size: 12px; white-space: nowrap; }
.req-no { color: var(--qt-muted); font-variant-numeric: tabular-nums; font-weight: 600; }

/* ───────── 목록: 업체 탭 / 상태 필터 / 그리드 ───────── */
.company-tabs { background: var(--qt-surface); border: 1px solid var(--qt-border); border-radius: var(--qt-radius) var(--qt-radius) 0 0; padding: 4px 8px 0; border-bottom: none; }
.company-tabs .dxbl-tabs { border-bottom: none; }
.tab-text { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.tab-count { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--qt-primary); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 600; }
.tab-count-zero { background: #d8dde6; color: #4b5563; }

.status-filter {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    padding: 12px; margin-bottom: 12px;
    background: var(--qt-surface); border: 1px solid var(--qt-border); border-radius: var(--qt-radius);
}
.company-tabs + .status-filter { border-top-left-radius: 0; border-top-right-radius: 0; }
.status-filter-sep { width: 1px; height: 20px; background: var(--qt-border); margin: 0 4px; }
.status-chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
    border: 1px solid var(--qt-border); background: #fff; color: var(--qt-text); cursor: pointer; font: inherit; font-size: 13px;
}
.status-chip b { font-variant-numeric: tabular-nums; color: var(--qt-muted); font-weight: 600; }
.status-chip:hover { border-color: #b8c2d4; }
.status-chip.active { background: var(--qt-primary); border-color: var(--qt-primary); color: #fff; }
.status-chip.active b { color: #fff; }

.req-grid, .admin-grid { background: var(--qt-surface); border-radius: var(--qt-radius); }
.req-row { cursor: pointer; }
.req-row-closed td { color: var(--qt-muted); }
.row-inactive td { color: #9ca3af; background: #fafafa; }
.req-title-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.req-title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.req-meta { flex: none; font-size: 12px; color: var(--qt-muted); }
.req-meta-comment { color: var(--qt-primary); font-weight: 600; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.count-link { text-decoration: none; color: var(--qt-text); }
.count-link b { color: var(--qt-primary); }

.empty-state { text-align: center; padding: 56px 16px; background: var(--qt-surface); border: 1px dashed #cdd4e0; border-radius: var(--qt-radius); }
.empty-icon { font-size: 40px; }
.empty-state h3 { margin: 8px 0 4px; }
.empty-state p { color: var(--qt-muted); margin: 0 0 16px; }

/* ───────── 상세 ───────── */
.detail-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; min-height: 34px; }
.back-link { text-decoration: none; color: var(--qt-muted); font-weight: 500; }
.back-link:hover { color: var(--qt-primary); }
.detail-actions { display: flex; gap: 8px; }

.detail-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.detail-side { position: sticky; top: 72px; }
.detail-head { border-bottom: 1px solid var(--qt-border); padding-bottom: 14px; margin-bottom: 16px; }
.detail-head-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.company-link { font-weight: 600; text-decoration: none; }
.detail-title { margin: 0 0 8px; font-size: 22px; line-height: 1.35; word-break: keep-all; overflow-wrap: anywhere; }
.detail-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; color: var(--qt-muted); font-size: 13px; }
.dot { color: #c2c8d2; }
.detail-content { white-space: pre-wrap; line-height: 1.75; font-size: 15px; overflow-wrap: anywhere; min-height: 60px; }
.detail-section-title { margin: 24px 0 10px; font-weight: 700; }
.detail-lock-note { margin-top: 20px; }

.comments-empty { margin: 0 0 12px; }
.comment { padding: 14px 16px; border-radius: 10px; border: 1px solid var(--qt-border); margin-bottom: 10px; background: #fff; }
.comment-admin { background: #fffbeb; border-color: #f6e3a9; }
.comment-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.comment-author { font-weight: 700; }
.comment-time { color: var(--qt-muted); font-size: 12px; margin-left: 4px; }
.comment-tools { margin-left: auto; display: flex; gap: 10px; font-size: 12.5px; }
.comment-body { white-space: pre-wrap; line-height: 1.65; overflow-wrap: anywhere; }
.comment-editor { width: 100%; }
.comment-edit-actions, .comment-new-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.comment .thumb-list { margin-top: 10px; }
.comment-new { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--qt-border); display: flex; flex-direction: column; gap: 8px; }

.side-status { margin-bottom: 12px; }
.side-status .status-badge { font-size: 14px; padding: 4px 16px; }
.status-change { display: flex; flex-direction: column; gap: 6px; padding-top: 12px; border-top: 1px solid var(--qt-border); }
.status-change .dxbl-btn { margin-top: 6px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-top: 4px; }

.side-info dl { display: grid; grid-template-columns: 56px 1fr; gap: 6px 8px; margin: 0; font-size: 13px; }
.side-info dt { color: var(--qt-muted); }
.side-info dd { margin: 0; }

/* ───────── 사진 썸네일 / 업로더 / 뷰어 ───────── */
.thumb-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.thumb { position: relative; width: 132px; border-radius: 8px; border: 1px solid var(--qt-border); background: #fff; overflow: hidden; }
.thumb-list-small .thumb { width: 92px; }
.thumb-open { display: block; width: 100%; padding: 0; border: none; background: #f3f5f9; cursor: zoom-in; }
.thumb img, .thumb-placeholder { display: block; width: 100%; aspect-ratio: 1 / 1; object-fit: cover; }
.thumb-placeholder { display: grid; place-items: center; font-size: 28px; background: #f3f5f9; }
.thumb-caption { padding: 4px 6px; font-size: 11.5px; color: var(--qt-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb-remove {
    position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
    border: none; background: rgba(17, 24, 39, .65); color: #fff; cursor: pointer; font-size: 13px; line-height: 24px; padding: 0;
}
.thumb-remove:hover { background: var(--qt-danger); }
.thumb-tag { position: absolute; left: 4px; top: 4px; padding: 0 6px; border-radius: 4px; background: var(--qt-primary); color: #fff; font-size: 11px; line-height: 18px; }
.thumb-tag-danger { background: var(--qt-danger); }
.thumb-removed img { opacity: .3; filter: grayscale(1); }
.thumb-pending { border-color: #b9cdf7; }

.uploader {
    position: relative; margin-top: 8px; border: 2px dashed #c6cfdd; border-radius: 10px; background: #fafbfd;
    transition: border-color .15s, background .15s;
}
.uploader:hover, .uploader.drag-over { border-color: var(--qt-primary); background: var(--qt-primary-soft); }
.uploader-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 1; }
.uploader-input:disabled { cursor: default; }
.uploader-full { border-style: solid; background: #f6f7f9; }
.uploader-full:hover { border-color: #c6cfdd; background: #f6f7f9; }
.uploader-hint { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px 12px; text-align: center; color: #4b5563; pointer-events: none; }
.uploader-hint small { color: var(--qt-muted); }
.uploader-icon { font-size: 24px; }
.uploader-compact .uploader-hint { flex-direction: row; justify-content: center; padding: 10px 12px; font-size: 13px; }
.uploader-compact .uploader-icon { font-size: 18px; }
.uploader-errors { margin: 6px 0 0; padding-left: 18px; color: var(--qt-danger); font-size: 13px; }
.spin { display: inline-block; animation: qt-spin 1.2s linear infinite; }
@keyframes qt-spin { to { transform: rotate(360deg); } }

.image-viewer { position: relative; display: flex; align-items: center; justify-content: center; min-height: 240px; background: #111827; border-radius: 6px; }
.image-viewer img { max-width: 100%; max-height: 72vh; object-fit: contain; display: block; }
.viewer-nav {
    position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 64px; border: none; border-radius: 8px;
    background: rgba(255,255,255,.12); color: #fff; font-size: 36px; line-height: 1; cursor: pointer;
}
.viewer-nav:hover { background: rgba(255,255,255,.25); }
.viewer-prev { left: 8px; }
.viewer-next { right: 8px; }
.viewer-meta { margin-right: auto; color: var(--qt-muted); font-size: 12.5px; }
.viewer-action { text-decoration: none; }

/* ───────── 등록·수정 폼 ───────── */
.req-form { margin-top: 12px; }
.required::after { content: " *"; color: var(--qt-danger); }
.field-error, .validation-message { color: var(--qt-danger); font-size: 12.5px; margin-top: 2px; }
.form-alert { padding: 10px 14px; border-radius: 8px; margin: 12px 0; font-size: 13.5px; line-height: 1.55; }
.form-alert-danger { background: #fdecec; color: #8b1c1c; border: 1px solid #f5c2c2; }
.form-alert-info { background: var(--qt-primary-soft); color: #1e3a8a; border: 1px solid #c9d8fb; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.input-with-button { display: flex; gap: 6px; width: 100%; }
.input-with-button > :first-child { flex: 1; }

.credential-box { display: grid; grid-template-columns: 80px 1fr; gap: 8px 12px; margin: 12px 0; padding: 14px; background: #f7f9fc; border: 1px solid var(--qt-border); border-radius: 8px; }
.credential-box dt { color: var(--qt-muted); }
.credential-box dd { margin: 0; overflow-wrap: anywhere; }
.credential-box code { font-size: 15px; background: none; padding: 0; }

/* ───────── 로그인 / 비밀번호 변경 (정적 화면) ───────── */
.account-page {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px;
    background: radial-gradient(circle at 20% 10%, #3b5bdb22, transparent 45%), linear-gradient(160deg, #1e3a8a 0%, #172554 100%);
}
.account-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 32px; box-shadow: 0 20px 45px rgba(2, 6, 23, .35); }
.account-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.account-brand-title { font-weight: 800; font-size: 18px; color: var(--qt-primary-dark); }
.account-brand-sub { font-size: 13px; color: var(--qt-muted); }
.account-title { margin: 0 0 6px; font-size: 20px; }
.account-desc { margin: 0 0 16px; color: var(--qt-muted); font-size: 13.5px; line-height: 1.6; }
.account-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .field-label { margin: 0; }
.field-input {
    height: 42px; padding: 0 12px; border: 1px solid #cfd6e1; border-radius: 8px; font: inherit; font-size: 15px; color: var(--qt-text); background: #fff;
}
.field-input:focus { outline: none; border-color: var(--qt-primary); box-shadow: 0 0 0 3px #1d4ed833; }
.field-check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: #374151; cursor: pointer; }
.btn-primary-block {
    height: 44px; margin-top: 4px; border: none; border-radius: 8px; background: var(--qt-primary); color: #fff; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-primary-block:hover { background: var(--qt-primary-dark); }
.account-hint { margin: 18px 0 0; font-size: 12.5px; color: var(--qt-muted); text-align: center; }
.account-links { display: flex; justify-content: space-between; margin-top: 18px; font-size: 13px; }
.account-footer { margin-top: 20px; font-size: 12px; color: rgba(255,255,255,.55); }

/* ───────── 반응형 ───────── */
@media (max-width: 1000px) {
    .detail-layout { grid-template-columns: 1fr; }
    .detail-side { position: static; }
}
@media (max-width: 720px) {
    .app-header { gap: 12px; padding: 0 12px; }
    .app-brand-sub, .app-user-name, .app-user-badge { display: none; }
    .app-main { padding: 14px; }
    .page-head { flex-direction: column; align-items: stretch; }
    .thumb { width: 104px; }
}

/* ───────── Blazor 기본 ───────── */
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "오류가 발생했습니다." }
