:root {
  --ink: #17211b;
  --muted: #68746d;
  --line: #dfe6e1;
  --canvas: #f4f7f5;
  --surface: #ffffff;
  --green: #176f4c;
  --green-dark: #0f5238;
  --green-soft: #e8f4ed;
  --amber: #9a5b12;
  --amber-soft: #fff4dc;
  --red: #a13c3c;
  --red-soft: #fceaea;
  --shadow: 0 12px 30px rgba(24, 48, 35, .07);
  --radius: 16px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body { margin: 0; min-height: 100vh; background: var(--canvas); color: var(--ink); }
a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-dark); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #0b57d0; outline-offset: 3px; }
.sidebar a:focus-visible, .sidebar button:focus-visible { outline-color: #ffd166; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 26px 18px 20px; background: #102c21; color: #fff; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 25px; color: #fff; }
.brand:hover { color: #fff; }
.brand-mark { display: inline-grid; place-items: center; flex: 0 0 40px; width: 40px; height: 40px; border-radius: 12px; background: #d8f0df; color: #144c36; font-weight: 800; font-size: 19px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.brand strong { display: block; font-size: 17px; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 3px; color: #9fb8aa; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.nav-list { display: grid; gap: 5px; }
.nav-section-label { margin: 17px 13px 5px; color: #759587; font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.nav-section-label:first-child { margin-top: 0; }
.nav-list a { display: flex; align-items: center; min-height: 44px; padding: 0 13px; border-radius: 10px; color: #c9d8d0; font-size: 14px; font-weight: 650; }
.nav-list a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-list a[aria-current="page"] { background: #fff; color: #153e2d; box-shadow: 0 7px 18px rgba(0,0,0,.13); }
.sidebar-footer { margin-top: auto; padding: 16px 10px 2px; border-top: 1px solid rgba(255,255,255,.1); color: #a9beb2; font-size: 12px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #5bdd96; box-shadow: 0 0 0 4px rgba(91,221,150,.11); }
.main-column { min-width: 0; }
.topbar { min-height: 92px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px clamp(22px, 4vw, 48px); background: rgba(255,255,255,.88); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 2px 0 0; font-size: clamp(22px, 2.4vw, 29px); letter-spacing: -.045em; }
.eyebrow { margin: 0; color: var(--green); font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.content { width: min(1480px, 100%); margin: 0 auto; padding: 32px clamp(18px, 4vw, 48px) 60px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.stat-card span, .stat-card small { display: block; color: var(--muted); font-size: 12px; }
.stat-card strong { display: block; margin: 9px 0 6px; font-size: 30px; letter-spacing: -.04em; line-height: 1.1; }
.stat-card .stat-date { font-size: 22px; }
.dashboard-grid, .answer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.panel { min-width: 0; margin-bottom: 20px; padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.dashboard-grid > .panel, .answer-grid > .panel { margin-bottom: 0; }
.panel-heading, .detail-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.panel-heading h2, .detail-heading h2 { margin: 4px 0 0; font-size: 19px; letter-spacing: -.025em; }
.panel-heading > a, .count-label { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.list-stack { display: grid; gap: 1px; }
.list-row { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 2px; border-bottom: 1px solid #edf1ee; color: var(--ink); }
.list-row:last-child { border-bottom: 0; }
.list-row span:first-child { min-width: 0; }
.list-row strong, .list-row small { display: block; }
.list-row strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.list-row small { overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.danger-panel { border-color: #efd1d1; }

.badge { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 9px; border-radius: 999px; background: var(--green-soft); color: var(--green-dark); font-size: 11px; font-weight: 750; white-space: nowrap; }
.badge-completed, .badge-no_evidence { background: var(--green-soft); color: var(--green-dark); }
.badge-running, .badge-pending { background: var(--amber-soft); color: var(--amber); }
.badge-failed { background: var(--red-soft); color: var(--red); }
.badge-neutral { background: #edf1ee; color: #59665f; }
.alert { margin-bottom: 18px; padding: 13px 16px; border: 1px solid #c9dfd0; border-radius: 11px; background: var(--green-soft); color: var(--green-dark); font-size: 13px; }
.alert-error { border-color: #edcaca; background: var(--red-soft); color: var(--red); }

.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; padding: 8px 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 750; font-size: 13px; }
.button-primary { background: var(--green); color: #fff; box-shadow: 0 6px 14px rgba(23,111,76,.18); }
.button-primary:hover { background: var(--green-dark); color: #fff; }
.button-quiet { border-color: var(--line); background: #fff; color: #39483f; box-shadow: none; }
.button-full { width: 100%; }
.inline-actions { display: inline-flex; margin: 8px 8px 0 0; }
.link-button { padding: 0; border: 0; background: transparent; color: var(--green); font-weight: 750; }

.form-stack { display: grid; gap: 18px; }
label { display: grid; gap: 7px; color: #34433a; font-size: 12px; font-weight: 750; }
label small { color: var(--muted); font-weight: 450; line-height: 1.5; }
input, select, textarea { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid #ccd7d0; border-radius: 9px; outline: 0; background: #fff; color: var(--ink); }
input[type="checkbox"], input[type="radio"] { width: 20px; min-height: 20px; padding: 0; accent-color: var(--green); }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(23,111,76,.12); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.filter-grid { display: grid; grid-template-columns: minmax(180px, 1.5fr) repeat(4, minmax(130px, 1fr)) auto; align-items: end; gap: 14px; }
.filter-actions { display: flex; gap: 8px; }
.switch-row { grid-template-columns: auto 1fr; align-items: center; padding: 15px; border: 1px solid var(--line); border-radius: 10px; }
.switch-row input { width: 20px; min-height: 20px; accent-color: var(--green); }
.switch-row strong, .switch-row small { display: block; }
.users-layout { grid-template-columns: minmax(260px, .7fr) minmax(0, 1.3fr); }

.table-panel { padding: 0; overflow: hidden; }
.table-panel > .panel-heading { padding: 23px 24px 0; }
.table-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-inline: contain; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 16px; background: #f7f9f8; color: var(--muted); text-align: left; font-size: 11px; letter-spacing: .04em; white-space: nowrap; }
td { max-width: 420px; padding: 15px 16px; border-top: 1px solid #e8edea; vertical-align: middle; }
.message-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.table-subtext { display: block; margin-top: 5px; color: var(--muted); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 17px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.empty-inline { margin: 0; padding: 28px 22px; color: var(--muted); text-align: center; }

.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.page-actions form { margin: 0; }
.detail-card { max-width: 980px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; overflow: hidden; margin: 0 0 22px; border: 1px solid var(--line); border-radius: 11px; background: var(--line); }
.detail-grid > div { min-width: 0; padding: 14px; background: #fff; }
dt { color: var(--muted); font-size: 11px; font-weight: 750; }
dd { overflow-wrap: anywhere; margin: 6px 0 0; font-size: 13px; }
.document-block { margin-top: 17px; padding: 18px; border-radius: 11px; background: #f5f8f6; }
.document-block h3 { margin: 0 0 10px; font-size: 13px; }
pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.75; }
.answer-text { padding: 17px; border-radius: 11px; background: #f5f8f6; font-size: 13px; }
.intro-panel p:last-child { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.empty-state { max-width: 560px; margin: 80px auto; text-align: center; }
.empty-state p { margin-bottom: 24px; color: var(--muted); }
.error-code { color: var(--green); font-size: 46px; font-weight: 850; }

/* Knowledge wiki */
.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: -8px 0 18px; color: var(--muted); font-size: 12px; }
.breadcrumbs a { font-weight: 700; }
.section-heading, .wiki-page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 22px; }
.section-heading h2, .wiki-page-header h2 { margin: 5px 0 0; font-size: clamp(25px, 3vw, 35px); letter-spacing: -.045em; }
.section-heading > div > p:last-child, .wiki-aliases { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.section-heading .page-actions { flex: 0 0 auto; margin: 0; }
.wiki-search-panel { padding: 18px; }
.wiki-search-panel .filter-grid { grid-template-columns: minmax(240px, 2fr) repeat(2, minmax(140px, .7fr)) auto; }
.wiki-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.wiki-index-group { margin: 0; }
.wiki-document-list { margin: 0; padding: 0; list-style: none; }
.wiki-document-list li { padding: 15px 0; border-top: 1px solid #edf1ee; }
.wiki-document-list li:first-child { border-top: 0; padding-top: 0; }
.wiki-document-list a { font-weight: 800; }
.wiki-document-list p { overflow-wrap: anywhere; margin: 6px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.wiki-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 330px); align-items: start; gap: 26px; }
.wiki-article, .wiki-infobox { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.wiki-article { padding: clamp(22px, 4vw, 42px); }
.wiki-infobox { position: sticky; top: 112px; overflow: hidden; }
.wiki-infobox-heading { padding: 20px 22px 17px; background: #f0f6f2; border-bottom: 1px solid var(--line); }
.wiki-infobox-heading h3 { margin: 4px 0 0; font-size: 18px; }
.wiki-infobox dl { margin: 0; }
.wiki-infobox dl > div { display: grid; grid-template-columns: minmax(84px, .7fr) minmax(0, 1fr); gap: 12px; padding: 13px 20px; border-bottom: 1px solid #edf1ee; }
.wiki-infobox dt { padding-top: 2px; }
.wiki-infobox dd { margin: 0; line-height: 1.5; overflow-wrap: anywhere; }
.infobox-history-link { display: block; min-height: 42px; padding: 13px 20px; font-size: 12px; font-weight: 750; }
.wiki-takeaway { margin-bottom: 30px; padding: 19px 21px; border: 1px solid #bddbc9; border-left: 4px solid var(--green); border-radius: 10px; background: var(--green-soft); }
.wiki-takeaway strong { color: var(--green-dark); font-size: 13px; }
.wiki-takeaway p { margin: 7px 0 0; line-height: 1.7; }
.wiki-section { padding: 5px 0 28px; }
.wiki-section + .wiki-section { padding-top: 25px; border-top: 1px solid var(--line); }
.wiki-section h3 { margin: 0 0 15px; font-size: 18px; letter-spacing: -.02em; }
.wiki-lead { margin: 0; font-size: 16px; line-height: 1.85; }
.wiki-body { margin: 0; color: #29372f; line-height: 1.9; overflow-wrap: anywhere; }
.wiki-links ul { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.wiki-links li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding: 11px 13px; border-radius: 8px; background: #f6f8f7; }
.wiki-links li span { color: var(--muted); font-size: 12px; }
.wiki-sources { padding-bottom: 0; }
.wiki-sources ol { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: sources; }
.wiki-sources li { position: relative; padding: 15px 16px 15px 46px; border: 1px solid var(--line); border-radius: 10px; overflow-wrap: anywhere; counter-increment: sources; }
.wiki-sources li::before { content: counter(sources); position: absolute; left: 15px; top: 15px; display: grid; place-items: center; width: 21px; height: 21px; border-radius: 50%; background: var(--green-soft); color: var(--green-dark); font-size: 11px; font-weight: 800; }
.source-meta { display: flex; flex-wrap: wrap; gap: 5px 12px; color: var(--muted); font-size: 11px; }
.wiki-sources li > p { margin: 8px 0; line-height: 1.65; }
.wiki-sources .source-note { color: var(--muted); font-size: 12px; }
.wiki-sources li > a { font-size: 12px; font-weight: 750; }
.empty-copy { color: var(--muted); font-size: 13px; }
.pre-wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.diff-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 16px 0; }
.diff-grid > section { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 10px; background: #f8faf9; overflow-wrap: anywhere; }
fieldset { min-width: 0; margin: 0; padding: 18px; border: 1px solid var(--line); border-radius: 11px; }
legend { padding: 0 7px; color: var(--ink); font-size: 13px; font-weight: 800; }
fieldset > label:has(input[type="checkbox"]) { grid-template-columns: 24px minmax(0, 1fr); align-items: center; min-height: 40px; }
.form-stack > .button, .form-stack > label { min-height: 40px; }
.panel > form + form { margin-top: 18px; }
.panel > h2:first-child { margin: 0; padding: 22px 24px 0; font-size: 18px; }

.auth-page { background: #102c21; }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 15%, #1d6145 0, #102c21 42%, #0b2118 100%); }
.auth-card { width: min(430px, 100%); padding: 38px; border: 1px solid rgba(255,255,255,.55); border-radius: 22px; background: rgba(255,255,255,.97); box-shadow: 0 30px 80px rgba(0,0,0,.26); }
.auth-brand { margin-bottom: 24px; }
.auth-card h1 { margin: 8px 0 10px; font-size: 29px; letter-spacing: -.045em; }
.muted { margin: 0 0 23px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.auth-note { margin: 22px 0 0; color: #7e8a83; font-size: 11px; text-align: center; }

.topic-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.topic-card { min-width: 0; }
.topic-samples { margin: 18px 0; padding-left: 20px; color: var(--muted); line-height: 1.55; }
.topic-samples li + li { margin-top: 8px; }
.setup-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.setup-steps a { display: grid; gap: 6px; padding: 15px; border: 1px solid var(--border); border-radius: 12px; background: #fbfdfc; color: inherit; text-decoration: none; }
.setup-steps a:hover, .setup-steps a:focus-visible { border-color: var(--green); box-shadow: 0 0 0 3px rgba(28, 106, 73, .1); }
.setup-steps span { color: var(--muted); font-size: 12px; line-height: 1.45; }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-actions { grid-column: span 1; }
}

@media (max-width: 880px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 15px 16px 12px; }
  .brand { padding: 0 2px 13px; }
  .brand-mark { width: 36px; height: 36px; flex-basis: 36px; }
  .nav-list { display: flex; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
  .nav-section-label { display: none; }
  .nav-list::-webkit-scrollbar { display: none; }
  .nav-list a { min-width: max-content; min-height: 44px; padding: 0 12px; }
  .sidebar-footer { display: none; }
  .topbar { position: sticky; top: 0; z-index: 10; min-height: 72px; padding: 14px 18px; }
  .topbar .eyebrow { display: none; }
  .content { padding-top: 20px; }
  .dashboard-grid, .answer-grid, .users-layout, .topic-grid, .setup-steps { grid-template-columns: 1fr; }
  .section-heading, .wiki-page-header { align-items: flex-start; flex-direction: column; }
  .section-heading .page-actions { width: 100%; }
  .wiki-card-grid, .wiki-layout { grid-template-columns: 1fr; }
  .wiki-article { order: 1; }
  .wiki-infobox { position: static; order: 2; }
  .wiki-search-panel .filter-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 620px) {
  .stat-grid { gap: 10px; }
  .stat-card { padding: 17px; }
  .stat-card strong { font-size: 24px; }
  .stat-card .stat-date { font-size: 17px; }
  .panel { padding: 18px; border-radius: 13px; }
  .table-panel { padding: 0; }
  .table-panel > .panel-heading { padding: 18px 18px 0; }
  .filter-grid, .form-grid { grid-template-columns: 1fr; }
  .wiki-search-panel .filter-grid, .diff-grid { grid-template-columns: 1fr; }
  .filter-actions { grid-column: auto; }
  .filter-actions .button { flex: 1; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-heading { align-items: flex-start; flex-direction: column; }
  .topbar h1 { font-size: 20px; }
  .auth-card { padding: 28px 22px; }
  td, th { padding-left: 13px; padding-right: 13px; }
  .wiki-article { padding: 20px 17px; }
  .wiki-page-header .badge { margin-top: -10px; }
  .wiki-infobox dl > div { grid-template-columns: minmax(90px, .8fr) minmax(0, 1fr); }
}
