/* =========================================================
   K-Gearbox · IEC 61400-4 T4 Test Suite
   ========================================================= */
:root {
    --ink: #14202e;
    --ink-2: #3c4a5a;
    --muted: #6b7887;
    --line: #dde3ea;
    --bg: #f4f6f9;
    --panel: #ffffff;
    --navy: #0f2233;
    --navy-2: #173248;
    --accent: #1f7a8c;      /* steel teal */
    --accent-soft: #e3f1f4;
    --ed1: #1f7a8c;         /* Ed.1 field test */
    --ed1-soft: #e3f1f4;
    --ed2: #c2621a;         /* Ed.2 integrated system test */
    --ed2-soft: #fbeee3;
    --ok: #2e7d4f;
    --ok-soft: #e4f3ea;
    --warn: #a86b00;
    --warn-soft: #fdf3dc;
    --bad: #b3261e;
    --bad-soft: #fbe7e5;
    --mono: "Cascadia Mono", Consolas, "D2Coding", ui-monospace, monospace;
}

html { font-size: 15px; }
body {
    font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
    color: var(--ink);
    background: var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.app-main { flex: 1 0 auto; padding-bottom: 3rem; }

/* ---------- Header / navigation ---------- */
.app-header { background: var(--navy); position: sticky; top: 0; z-index: 1030; box-shadow: 0 1px 0 rgba(255,255,255,.06); }
.app-header .navbar { padding-top: .45rem; padding-bottom: .45rem; }
.brand-mark { color: #7fc8d6; display: inline-flex; }
.brand-title { display: block; font-weight: 800; letter-spacing: .02em; font-size: 1.05rem; line-height: 1.1; color: #fff; }
.brand-sub { display: block; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; color: #9db3c6; }
.app-header .nav-link {
    color: #c9d6e2 !important;
    font-size: .9rem;
    padding: .5rem .7rem !important;
    border-radius: 6px;
    display: flex; align-items: center; gap: .35rem;
    white-space: nowrap;
}
.app-header .nav-link:hover { color: #fff !important; background: rgba(255,255,255,.07); }
.app-header .nav-link.active { color: #fff !important; background: var(--accent); }
.nav-step { font-family: var(--mono); font-size: .68rem; opacity: .65; }
.app-header .nav-link.active .nav-step { opacity: .9; }

/* ---------- Page header ---------- */
.page-head { background: var(--panel); border-bottom: 1px solid var(--line); padding: 1.6rem 0 1.3rem; margin-bottom: 1.5rem; }
.page-step { font-family: var(--mono); font-size: .75rem; letter-spacing: .12em; color: var(--accent); font-weight: 700; }
.page-title { font-size: 1.65rem; font-weight: 800; margin: .15rem 0 .35rem; letter-spacing: -.01em; }
.page-lead { color: var(--ink-2); margin: 0; max-width: 62rem; }
.std-chip { font-size: .75rem; border: 1px solid var(--line); background: var(--bg); color: var(--ink-2); padding: .2rem .55rem; border-radius: 999px; white-space: nowrap; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1.15rem 1.25rem; margin-bottom: 1.25rem; }
.panel-title { font-size: 1.02rem; font-weight: 700; margin: 0 0 .85rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.panel-title .hint { font-weight: 400; color: var(--muted); font-size: .82rem; }
.section-label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin-bottom: .5rem; }

/* ---------- KPI tiles ---------- */
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; height: 100%; }
.kpi-label { font-size: .78rem; color: var(--muted); }
.kpi-value { font-size: 1.6rem; font-weight: 800; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .78rem; color: var(--ink-2); }

/* ---------- Tables ---------- */
.table-k { font-size: .87rem; margin-bottom: 0; }
.table-k thead th { background: #eef2f6; color: var(--ink-2); font-weight: 700; font-size: .78rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table-k td, .table-k th { vertical-align: middle; padding: .5rem .6rem; border-color: var(--line); }
.table-k .num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: .82rem; }
.mono { font-family: var(--mono); font-size: .82rem; }
.table-k td.mono, .table-k td.num, .table-k .mono.small { white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }

/* ---------- Badges ---------- */
.badge-ed { display: inline-block; font-size: .7rem; font-weight: 700; padding: .18rem .5rem; border-radius: 4px; white-space: nowrap; }
.badge-ed1 { background: var(--ed1-soft); color: var(--ed1); }
.badge-ed2 { background: var(--ed2-soft); color: var(--ed2); }
.badge-common { background: #eceff3; color: var(--ink-2); }
.st { display: inline-block; font-size: .72rem; font-weight: 700; padding: .16rem .5rem; border-radius: 999px; white-space: nowrap; }
.st-ok { background: var(--ok-soft); color: var(--ok); }
.st-warn { background: var(--warn-soft); color: var(--warn); }
.st-bad { background: var(--bad-soft); color: var(--bad); }
.st-info { background: var(--accent-soft); color: var(--accent); }
.st-mute { background: #eceff3; color: var(--muted); }

/* ---------- Progress ---------- */
.bar { height: 6px; background: #e8edf2; border-radius: 3px; overflow: hidden; min-width: 80px; }
.bar > span { display: block; height: 100%; background: var(--accent); }
.bar.ed2 > span { background: var(--ed2); }

/* ---------- Main page (hero) ---------- */
.hero { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 60%, #1d4a60 100%); color: #fff; padding: 3.2rem 0 2.8rem; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -120px; top: -120px; width: 520px; height: 520px; border-radius: 50%; border: 60px solid rgba(127,200,214,.07); }
.hero-kicker { font-family: var(--mono); font-size: .78rem; letter-spacing: .14em; color: #7fc8d6; font-weight: 700; }
.hero h1 { font-size: 2.15rem; font-weight: 800; line-height: 1.3; margin: .6rem 0 1rem; letter-spacing: -.015em; }
.hero p { color: #c9d6e2; font-size: 1.05rem; max-width: 52rem; }
.hero .btn-hero { background: #7fc8d6; color: var(--navy); font-weight: 700; border: 0; }
.hero .btn-hero:hover { background: #a3dbe5; }
.hero .btn-ghost { border: 1px solid rgba(255,255,255,.35); color: #fff; }
.hero .btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }

.edition-card { border-radius: 10px; padding: 1.25rem 1.35rem; height: 100%; border: 1px solid var(--line); background: var(--panel); border-top: 4px solid var(--ed1); }
.edition-card.ed2 { border-top-color: var(--ed2); }
.edition-card h3 { font-size: 1.1rem; font-weight: 800; margin-bottom: .2rem; }
.edition-card .sub { color: var(--muted); font-size: .85rem; margin-bottom: .8rem; }
.edition-card ul { padding-left: 1.1rem; margin: 0; }
.edition-card li { margin-bottom: .3rem; }

.flow { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; }
@media (max-width: 991.98px) { .flow { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 575.98px) { .flow { grid-template-columns: 1fr; } }
.flow-card { display: block; text-decoration: none; color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.05rem; transition: border-color .15s, transform .15s, box-shadow .15s; height: 100%; }
.flow-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(15,34,51,.08); color: inherit; }
.flow-num { font-family: var(--mono); font-size: .8rem; color: var(--accent); font-weight: 700; }
.flow-title { font-weight: 800; margin: .2rem 0 .35rem; }
.flow-desc { font-size: .84rem; color: var(--ink-2); margin: 0; }

.goal { display: flex; gap: .9rem; }
.goal-n { flex: 0 0 2rem; height: 2rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.goal h4 { font-size: .98rem; font-weight: 700; margin: .25rem 0 .25rem; }
.goal p { font-size: .87rem; color: var(--ink-2); margin: 0; }

/* ---------- Process steps ---------- */
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 .95rem 2.4rem; border-left: 2px solid var(--line); margin-left: .85rem; }
.steps li:last-child { border-left-color: transparent; padding-bottom: 0; }
.steps li::before { content: counter(s); position: absolute; left: -.9rem; top: -.1rem; width: 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--panel); border: 2px solid var(--accent); color: var(--accent); font-weight: 800; font-size: .8rem; display: flex; align-items: center; justify-content: center; }
.steps.ed2 li::before { border-color: var(--ed2); color: var(--ed2); }
.steps b { display: block; }
.steps span { font-size: .85rem; color: var(--ink-2); }

/* ---------- Tabs ---------- */
.nav-tabs .nav-link { color: var(--ink-2); font-weight: 600; }
.nav-tabs .nav-link.active { color: var(--accent); }

/* ---------- Charts / live ---------- */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.live-dot { width: .6rem; height: .6rem; border-radius: 50%; background: var(--ok); display: inline-block; box-shadow: 0 0 0 0 rgba(46,125,79,.6); animation: pulse 1.6s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(46,125,79,.55); } 70% { box-shadow: 0 0 0 .55rem rgba(46,125,79,0); } 100% { box-shadow: 0 0 0 0 rgba(46,125,79,0); } }
.signal-row { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; padding: .55rem 0; border-bottom: 1px dashed var(--line); font-size: .87rem; }
.signal-row:last-child { border-bottom: 0; }
.signal-val { font-family: var(--mono); font-weight: 700; text-align: right; }

/* ---------- Architecture diagram ---------- */
.arch svg { width: 100%; height: auto; }
.arch text { font-family: "Malgun Gothic", system-ui, sans-serif; }

/* ---------- Forms ---------- */
.form-label { font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }
.form-control, .form-select { font-size: .9rem; }
.btn-accent { background: var(--accent); color: #fff; border: 0; }
.btn-accent:hover { background: #18606e; color: #fff; }

/* ---------- Report preview ---------- */
.doc-preview { background: #fff; border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(15,34,51,.08); padding: 2rem 2.2rem; font-size: .88rem; }
.doc-preview h5 { font-weight: 800; border-bottom: 2px solid var(--ink); padding-bottom: .4rem; }
.doc-preview .doc-sec { font-weight: 700; margin-top: 1rem; }
.doc-preview table { width: 100%; font-size: .82rem; }
.doc-preview td { border: 1px solid var(--line); padding: .3rem .5rem; }
.doc-preview td:first-child { background: #f5f7fa; width: 32%; font-weight: 600; }

/* ---------- Footer ---------- */
.app-footer { background: var(--navy); color: #8fa5b8; font-size: .78rem; padding: 1rem 0; }

@media (max-width: 1199.98px) {
    .app-header .navbar-nav { padding: .5rem 0; }
}
@media (max-width: 767.98px) {
    .hero h1 { font-size: 1.6rem; }
    .page-title { font-size: 1.35rem; }
}

/* ---------- Project bar (현재 시험 사업) ---------- */
.project-bar { background: var(--navy-2); color: #9db3c6; font-size: .76rem; padding: .3rem 0; border-top: 1px solid rgba(255,255,255,.06); }
.project-bar .mono { color: #7fc8d6; font-size: .74rem; }

/* ---------- Clause chips / key-value ---------- */
.clause { display: inline-block; font-family: var(--mono); font-size: .72rem; background: #eef2f6; color: var(--ink-2); border-radius: 4px; padding: .05rem .4rem; white-space: nowrap; }
.clause.ed1 { background: var(--ed1-soft); color: var(--ed1); }
.clause.ed2 { background: var(--ed2-soft); color: var(--ed2); }
.kv th { width: 38%; color: var(--ink-2); font-weight: 600; background: #f7f9fb; }
.note { font-size: .8rem; color: var(--muted); }
.verify-ok { color: var(--ok); font-weight: 700; }
.verify-no { color: var(--warn); font-weight: 700; }
.hash { font-family: var(--mono); font-size: .72rem; color: var(--muted); white-space: nowrap; }
.stage-row { display: flex; gap: .25rem; flex-wrap: wrap; }
.table-k tr.sel td { background: var(--accent-soft); }

/* ---------- CSP: style 속성 대신 쓰는 클래스 (docs/security.md 6) ---------- */
.hero-inner { position: relative; z-index: 1; }
.text-accent { color: var(--accent); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.panel-accent { border-top: 4px solid var(--accent); }
.w-22 { width: 22%; }
.w-44 { width: 44%; }
.mw-220 { max-width: 220px; }
.mw-260 { max-width: 260px; }
.min-66 { min-width: 66px; } .min-76 { min-width: 76px; } .min-84 { min-width: 84px; } .min-90 { min-width: 90px; }
.min-110 { min-width: 110px; } .min-210 { min-width: 210px; } .min-220 { min-width: 220px; } .min-300 { min-width: 300px; }
.chart-box.h-200 { height: 200px; } .chart-box.h-220 { height: 220px; } .chart-box.h-260 { height: 260px; }
.chart-box.h-280 { height: 280px; } .chart-box.h-300 { height: 300px; }
.scroll-220 { max-height: 220px; overflow-y: auto; }
.scroll-260 { max-height: 260px; overflow-y: auto; }
.scroll-520 { max-height: 520px; overflow-y: auto; }
.st-wrap { white-space: normal; }
.tree-box { background: #f5f7fa; border: 1px solid var(--line); border-radius: 6px; padding: .8rem; white-space: pre; }
.gantt-bar { height: 14px; border-radius: 3px; }
.gantt-today { box-shadow: inset 2px 0 0 #b3261e; }
.row-bad td { background: var(--bad-soft); }

/* ---------- 사용자 표시 (머리 띠) ---------- */
.user-chip { color: #dbe6ef; }
.user-role { font-size: .68rem; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; padding: 0 .4rem; margin-left: .25rem; }
.bar-link { color: #9db3c6; text-decoration: none; }
.bar-link:hover { color: #fff; }
.btn-bar { font-size: .72rem; padding: 0 .5rem; }

/* ---------- 로그인·계정 설정 화면 ---------- */
.auth-body { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 70%, #1d4a60 100%); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-card { background: var(--panel); border-radius: 12px; width: 100%; max-width: 420px; box-shadow: 0 12px 40px rgba(0,0,0,.25); overflow: hidden; }
.auth-card.auth-wide { max-width: 640px; }
.auth-brand { display: flex; align-items: center; gap: .6rem; background: var(--navy); padding: .9rem 1.25rem; }
.auth-body-inner { padding: 1.4rem 1.5rem 1rem; }
.auth-title { font-size: 1.35rem; font-weight: 800; margin-bottom: .35rem; }
.auth-lede { color: var(--ink-2); font-size: .9rem; }
.auth-hint { color: var(--muted); font-size: .78rem; margin: 1rem 0 0; }
.auth-facts { width: 100%; font-size: .74rem; color: var(--muted); border-top: 1px solid var(--line); background: #f7f9fb; }
.auth-facts th { padding: .3rem .5rem .3rem 1.5rem; white-space: nowrap; font-weight: 600; vertical-align: top; width: 1%; }
.auth-facts td { padding: .3rem 1.5rem .3rem .5rem; }
.auth-steps { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; font-size: .78rem; }
.auth-steps span { border: 1px solid var(--line); border-radius: 999px; padding: .15rem .6rem; color: var(--muted); }
.auth-steps span[aria-current="step"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.code-input { font-family: var(--mono); font-size: 1.15rem; letter-spacing: .2em; }
.field-narrow { max-width: 220px; }
.secret { font-family: var(--mono); font-size: 1rem; letter-spacing: .06em; background: #f5f7fa; border: 1px dashed var(--line); border-radius: 6px; padding: .5rem .7rem; word-break: break-all; }
.codes { columns: 2; list-style: none; padding: 0; font-family: var(--mono); font-size: 1rem; margin-bottom: 1rem; }
.codes li { padding: .2rem 0; }
.otp-qr { display: grid; grid-template-columns: 180px 1fr; gap: 1rem; align-items: start; margin-bottom: 1rem; }
.otp-qr-code { width: 180px; height: 180px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.otp-qr-code svg { width: 100%; height: 100%; fill: #000; }
@media (max-width: 520px) { .otp-qr { grid-template-columns: 1fr; } .codes { columns: 1; } }

/* ---------- Print (최종 시험보고) ---------- */
@media print {
    .no-print, .app-header, .app-footer, .page-head { display: none !important; }
    body { background: #fff; }
    .app-main { padding: 0; }
    .doc-preview { box-shadow: none; border: 0; padding: 0; font-size: 10pt; }
    .doc-preview table { page-break-inside: auto; }
    .doc-preview tr { page-break-inside: avoid; }
    .col-print-full { width: 100% !important; flex: 0 0 100% !important; max-width: 100% !important; }
}
