:root {
    --bg-main: #f8f9fa;
    --bg-card: #ffffff;
    --bg-soft: #f1f3f5;
    --text-primary: #111111;
    --text-muted: #6c757d;
    --border-strong: #191919;
    --border-light: #dee2e6;
    --brand-orange: #ff7f00;
    --pro-green: #12b886;
}

html.dark {
    color-scheme: dark !important;
    --bg-main: #0f172a;
    --bg-card: #1e293b;
    --bg-soft: #334155;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --border-strong: #475569;
    --border-light: #334155;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Pretendard', 'Malgun Gothic', -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.orange-divider { height: 3px; background-color: #1e3a8a; width: 100%; }

.main-container {
    max-width: 1380px;
    margin: 0 auto;
    padding: 18px 16px 48px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.outline-card {
    background-color: var(--bg-card);
    border: 1.5px solid var(--border-strong);
    border-radius: 14px;
    padding: 16px 18px;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.card-title { font-size: 16px; font-weight: 900; }

/* 국제규격 선택 칩 */
.std-chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.std-chip {
    padding: 9px 14px;
    border-radius: 10px;
    border: 1.5px solid var(--border-light);
    background: var(--bg-soft);
    color: var(--text-primary);
    font-weight: 800;
    font-size: 13px;
    cursor: pointer;
}
.std-chip.active {
    background: var(--brand-orange);
    color: #fff;
    border-color: var(--brand-orange);
}
.std-chip.locked { opacity: 0.75; }
.std-bar-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.std-desc-box {
    flex: 1;
    min-width: 240px;
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--bg-soft);
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.cont-summary-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-soft);
    font-size: 12px;
    font-weight: 700;
}
.cont-sum-item { display: inline-flex; align-items: center; gap: 4px; }

/* 대시보드 KPI (간결한 얇은 외곽선 1줄 테이블형) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
@media (max-width: 1120px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 640px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi-card {
    background: var(--bg-soft);
    border: 1px solid var(--brand-orange);
    border-radius: 8px;
    padding: 7px 9px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}
.kpi-card.kpi-active { border-color: #12b886; }
.kpi-card.kpi-warn { border-color: #f59f00; }
.kpi-card.kpi-danger { border-color: #e03131; }
.kpi-card.kpi-muted { border-color: #868e96; }
.kpi-label { font-size: 11.5px; font-weight: 700; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 16px; font-weight: 900; line-height: 1; }

.proc-dist-wrap { display: flex; flex-direction: column; gap: 8px; }
.proc-bar-row { display: grid; grid-template-columns: 110px 1fr 78px; align-items: center; gap: 10px; font-size: 12px; font-weight: 700; }
.proc-bar-track { height: 10px; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.proc-bar-fill { height: 100%; background: var(--brand-orange); border-radius: 999px; }
.proc-bar-cnt { text-align: right; color: var(--text-muted); }

/* 툴바 & 필터 */
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.more-actions-drawer {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: var(--bg-soft);
    border: 1px solid var(--border-light);
}
.act-btn {
    padding: 8px 12px;
    border-radius: 9px;
    border: 1.5px solid var(--border-light);
    background: var(--bg-soft);
    color: var(--text-primary);
    font-size: 12.5px;
    font-weight: 800;
    cursor: pointer;
}
.act-btn.primary { background: var(--brand-orange); color: #fff; border-color: var(--brand-orange); }
.act-btn.green { background: #12b886; color: #fff; border-color: #12b886; }

.filter-bar {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
@media (max-width: 760px) { .filter-bar { grid-template-columns: 1fr 1fr; } }
.filter-bar input, .filter-bar select {
    padding: 9px 11px;
    border-radius: 8px;
    border: 1.5px solid var(--border-light);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 700;
}

/* 마스터 테이블 */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border-light);
    border-radius: 10px;
}
table.wqm-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
    min-width: 840px;
}
table.wqm-table th, table.wqm-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    vertical-align: middle;
}
table.wqm-table thead th {
    background: #e9ecef;
    font-weight: 900;
    font-size: 12px;
    color: var(--text-primary);
    letter-spacing: 0.1px;
    white-space: nowrap;
    border-bottom: 2px solid var(--brand-orange);
    border-right: 1px solid rgba(0, 0, 0, 0.06);
}
table.wqm-table thead th:last-child { border-right: none; }
html.dark table.wqm-table thead th {
    background: #334155;
    border-right-color: rgba(255, 255, 255, 0.08);
}
table.wqm-table tbody tr { transition: background-color 0.12s ease; }
table.wqm-table tbody tr:nth-child(even) { background: rgba(0, 0, 0, 0.03); }
html.dark table.wqm-table tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.03); }
table.wqm-table tbody tr:hover { background: rgba(255, 127, 0, 0.055); }
table.wqm-table tbody tr:last-child td { border-bottom: none; }
.cell-main { font-weight: 800; color: var(--text-primary); }
.cell-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.row-revoked { opacity: 0.55; background: rgba(134, 142, 150, 0.05); }
.row-expired { background: rgba(224, 49, 49, 0.05); }

.st-badge { display: inline-block; padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.st-active { background: #d3f9d8; color: #2b8a3e; }
.st-expiring { background: #fff3bf; color: #d9480f; }
.st-expired { background: #ffe3e3; color: #c92a2a; }
.st-revoked { background: #e9ecef; color: #495057; }

.act-cell { white-space: nowrap; }
.tbl-btn {
    padding: 5px 9px; border-radius: 6px; border: 1px solid var(--border-light);
    background: var(--bg-soft); color: var(--text-primary); font-size: 11px; font-weight: 800; cursor: pointer;
    transition: border-color 0.12s ease;
}
.tbl-btn:hover { border-color: var(--brand-orange); }
.tbl-btn-revoke { color: #c92a2a; }
.tbl-btn-restore { color: #087f5b; }

.cont-preset-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.cont-preset-chip {
    padding: 5px 10px; border-radius: 999px; border: 1px solid var(--border-light);
    background: var(--bg-soft); color: var(--text-primary); font-size: 11.5px; font-weight: 700; cursor: pointer;
}
.cont-preset-chip.active { background: var(--brand-orange); color: #fff; border-color: var(--brand-orange); }

/* 모달 */
.wqm-modal-overlay {
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
    display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 999;
}
.wqm-modal-box {
    width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto;
    background: var(--bg-card); color: var(--text-primary);
    border-radius: 16px; border: 1.5px solid var(--border-strong);
    padding: 18px 20px; box-shadow: 0 16px 40px rgba(0,0,0,0.25);
}
.wqm-modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding-bottom: 10px; margin-bottom: 14px; border-bottom: 2px solid var(--brand-orange);
}
.wqm-modal-head h3 { font-size: 16px; font-weight: 900; }
.wqm-modal-close {
    border: none; background: #1e3a8a; color: #ffffff;
    width: 30px; height: 30px; border-radius: 8px; font-weight: 900; cursor: pointer;
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 560px) { .form-grid-2 { grid-template-columns: 1fr; } }
.modal-form label, .lic-box label { display: block; font-size: 11.5px; font-weight: 800; margin-bottom: 4px; color: var(--text-muted); }
.modal-form input, .modal-form select, .lic-box input {
    width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--border-light);
    background: var(--bg-card); color: var(--text-primary); font-size: 13px; font-weight: 700;
}
.modal-desc { font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5; }
.modal-footer-btns { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; }
.btn-primary { padding: 9px 16px; border-radius: 8px; border: none; background: var(--brand-orange); color: #fff; font-weight: 800; cursor: pointer; }
.btn-secondary { padding: 9px 14px; border-radius: 8px; border: 1.5px solid var(--border-light); background: var(--bg-soft); color: var(--text-primary); font-weight: 800; cursor: pointer; }
.btn-close-blue { padding: 9px 14px; border-radius: 8px; border: none; background: #1e3a8a; color: #ffffff; font-weight: 800; cursor: pointer; }
.btn-danger { padding: 9px 14px; border-radius: 8px; border: none; background: #e03131; color: #fff; font-weight: 800; cursor: pointer; }

.sticker-opt-row { display: flex; gap: 16px; margin-bottom: 12px; font-size: 13px; font-weight: 700; }
.sticker-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; max-height: 360px; overflow-y: auto; padding: 8px; background: var(--bg-soft); border-radius: 10px; }

/* 도움말 아코디언 */
.help-acc-list { display: flex; flex-direction: column; gap: 8px; }
.help-acc {
    border: 1.5px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-soft);
    overflow: hidden;
}
.help-acc summary {
    padding: 11px 14px;
    font-size: 13.5px;
    font-weight: 900;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.help-acc summary::-webkit-details-marker { display: none; }
.help-acc summary::after { content: '▾'; font-size: 13px; color: var(--brand-orange); transition: transform 0.15s; }
.help-acc[open] summary::after { transform: rotate(180deg); }
.help-acc-body {
    padding: 10px 14px 12px 14px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-light);
    font-size: 12.5px;
    line-height: 1.65;
}
.help-acc-body ul { padding-left: 18px; margin: 0; }
.help-acc-body li + li { margin-top: 4px; }
