:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --panel: #ffffff;
  --panel-alt: #f8faf9;
  --ink: #202722;
  --muted: #68716b;
  --line: #dfe5e1;
  --line-strong: #c8d1cb;
  --accent: #16834d;
  --accent-strong: #0e6338;
  --accent-soft: #e8f4ed;
  --navy: #17362a;
  --ok: #16834d;
  --warn: #b17a20;
  --bad: #c1493f;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(21, 42, 32, 0.04), 0 12px 28px rgba(21, 42, 32, 0.06);
  font-family: Pretendard, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
input, select {
  width: 100%; min-height: 40px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; color: var(--ink); padding: 0 11px; outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(22, 131, 77, .12); }
label { display: grid; gap: 6px; color: #48514b; font-size: 12px; font-weight: 700; }
h1, h2, h3, h4, p { margin: 0; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
h4 { margin-top: 22px; font-size: 15px; }
.muted { color: var(--muted); font-size: 12px; }
.eyebrow { margin-bottom: 5px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.primary, .secondary, .text-button {
  min-height: 40px; border: 1px solid transparent; border-radius: 6px; padding: 0 15px; font-weight: 750;
}
.primary { background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-strong); }
.secondary { border-color: var(--line-strong); background: #fff; color: #364039; }
.secondary:hover { border-color: var(--accent); color: var(--accent-strong); }
.text-button { min-height: auto; border: 0; background: transparent; color: #d9ebe0; padding: 4px; }

.login-screen {
  display: grid; min-height: 100vh; place-items: center; padding: 24px;
  background:
    linear-gradient(135deg, rgba(28, 42, 34, .96), rgba(23, 122, 66, .9)),
    var(--navy);
}
.login-card {
  width: min(430px, 100%); padding: 36px;
  border: 1px solid rgba(255,255,255,.5); border-radius: 16px; background: rgba(255,255,255,.96);
  box-shadow: 0 28px 70px rgba(0, 0, 0, .25);
}
.login-brand { display: flex; align-items: center; gap: 16px; }
.login-brand img { width: 86px; height: 86px; object-fit: contain; }
.login-brand .eyebrow { margin-bottom: 4px; }
.login-brand h1 { color: var(--ink); font-size: 30px; }
.login-description { margin: 24px 0 20px; color: var(--muted); font-size: 15px; }
.login-form { display: grid; gap: 16px; }
.control-group { display: grid; gap: 6px; }
.login-form input { min-height: 48px; font-size: 16px; }
.login-button {
  min-height: 50px; margin-top: 4px; border: 0; border-radius: 11px;
  background: var(--accent); color: #fff; font-size: 16px; font-weight: 750;
}
.login-button:hover:not(:disabled) { background: var(--accent-strong); }
.login-error {
  padding: 10px 12px; border: 1px solid rgba(192, 86, 63, .25); border-radius: 10px;
  background: rgba(192, 86, 63, .08); color: var(--bad); font-size: 14px; font-weight: 700;
}
.form-status { min-height: 20px; color: var(--muted); font-size: 12px; font-weight: 650; }
.form-status.bad { color: var(--bad); }

.app-shell { display: grid; grid-template-columns: 270px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; width: 270px; padding: 18px;
  background: linear-gradient(180deg, #142b21, #19472f 55%, #14643a); color: #fff; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 13px; padding: 5px 4px 22px; }
.brand-mark { width: 58px; height: 58px; flex: 0 0 auto; object-fit: contain; }
.brand h1 { color: #fff; font-size: 19px; line-height: 1.18; }
.brand span { color: #bcd7c7; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.bridge-mini-status {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding: 12px;
  border: 1px solid rgba(255,255,255,.14); border-radius: var(--radius); background: rgba(255,255,255,.07);
}
.bridge-mini-status div { min-width: 0; }
.bridge-mini-status strong, .bridge-mini-status small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bridge-mini-status strong { font-size: 12px; }
.bridge-mini-status small { color: #bcd7c7; font-size: 10px; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #809087; box-shadow: 0 0 0 4px rgba(255,255,255,.08); }
.status-dot.ok { background: #58d08d; }
.status-dot.bad { background: #ef766a; }
.nav-list { display: grid; gap: 5px; }
.nav-button {
  min-height: 43px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: #d7e8de;
  padding: 0 13px; text-align: left; font-weight: 700;
}
.nav-button:hover { background: rgba(255,255,255,.08); }
.nav-button.active { border-color: rgba(255,255,255,.18); background: #fff; color: var(--accent-strong); }
.sidebar-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding: 18px 5px 3px; color: #d7e8de; font-size: 12px; }

.main-content { grid-column: 2; min-width: 0; padding: 24px 28px 40px; }
.topbar { display: flex; justify-content: space-between; align-items: center; min-height: 66px; margin-bottom: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.workspace-view { display: none; }
.workspace-view.active { display: block; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.metric-card, .panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); }
.metric-card { display: grid; gap: 4px; min-height: 120px; padding: 19px; }
.metric-card span { color: var(--muted); font-size: 11px; font-weight: 750; }
.metric-card strong { align-self: end; font-size: 25px; letter-spacing: -.03em; }
.metric-card small { color: var(--muted); }
.metric-card strong.ok { color: var(--ok); }
.metric-card strong.bad { color: var(--bad); }
.panel { margin-bottom: 14px; padding: 20px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.badge { border: 1px solid var(--line); border-radius: 999px; background: var(--panel-alt); color: var(--muted); padding: 5px 9px; font-size: 11px; font-weight: 750; }
.badge.ok { border-color: #abd8bf; background: var(--accent-soft); color: var(--accent-strong); }
.badge.bad { border-color: #efc1bd; background: #fbefee; color: var(--bad); }
.rate-grid { display: grid; grid-template-columns: repeat(8, minmax(95px, 1fr)); gap: 8px; }
.rate-card { padding: 14px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-alt); }
.rate-card span, .rate-card small { display: block; color: var(--muted); font-size: 10px; }
.rate-card strong { display: block; margin: 7px 0 4px; font-size: 21px; }
.diagnostic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.diagnostic-item { padding: 14px; border-left: 3px solid var(--line-strong); background: var(--panel-alt); }
.diagnostic-item.ok { border-color: var(--ok); }
.diagnostic-item.bad { border-color: var(--bad); }
.diagnostic-item span, .diagnostic-item small { display: block; color: var(--muted); font-size: 11px; }
.diagnostic-item strong { display: block; margin: 2px 0; }
.empty-state { grid-column: 1 / -1; padding: 28px; color: var(--muted); text-align: center; }

.history-guide {
  display: flex; align-items: center; gap: 16px; margin-bottom: 14px; padding: 14px 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow);
}
.history-guide > div { display: grid; grid-template-columns: 28px auto; column-gap: 9px; align-items: center; flex: 1; min-width: 0; }
.history-guide span, .step-heading > span {
  display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; font-size: 12px; font-weight: 800;
}
.history-guide span { grid-row: 1 / 3; width: 28px; height: 28px; }
.history-guide strong { font-size: 13px; }
.history-guide small { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.history-guide > b { color: var(--line-strong); }
.split-layout { display: grid; grid-template-columns: minmax(480px, .9fr) minmax(520px, 1.25fr); gap: 14px; align-items: start; }
.split-layout .panel { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.wide { grid-column: 1 / -1; }
.checkbox-label { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.checkbox-label input { width: 16px; min-height: 16px; }
.history-query-form { display: grid; gap: 16px; }
.history-step { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.history-step:first-child { padding-top: 0; border-top: 0; }
.step-heading { display: flex; align-items: center; gap: 10px; }
.step-heading > span { width: 25px; height: 25px; flex: 0 0 auto; }
.step-heading > div { display: grid; }
.step-heading strong { font-size: 13px; }
.step-heading small, .field-help { color: var(--muted); font-size: 11px; font-weight: 500; }
.compact-grid { gap: 10px; }
.field-picker-toolbar { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.field-option-list {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 250px; padding: 8px;
  overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-alt);
}
.field-option {
  display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 34px; padding: 6px 8px;
  border: 1px solid transparent; border-radius: 6px; background: #fff; color: #3f4942; font-size: 12px; font-weight: 650; cursor: pointer;
}
.field-option:hover { border-color: var(--line-strong); }
.field-option.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); }
.field-option input { width: 15px; min-height: 15px; flex: 0 0 auto; }
.field-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-fields-header { display: flex; justify-content: space-between; align-items: center; color: #48514b; font-size: 12px; }
.selected-fields-header span { color: var(--muted); }
.selected-field-list { display: flex; flex-wrap: wrap; gap: 6px; min-height: 31px; }
.selected-field-chip {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid #abd8bf; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-strong); padding: 5px 8px; font-size: 11px; font-weight: 750;
}
.selected-field-chip button { border: 0; background: transparent; color: inherit; padding: 0; font-weight: 900; line-height: 1; }
.advanced-options { border: 1px solid var(--line); border-radius: 6px; background: var(--panel-alt); }
.advanced-options summary { padding: 10px 12px; color: #48514b; font-size: 12px; font-weight: 750; cursor: pointer; }
.advanced-options[open] summary { border-bottom: 1px solid var(--line); }
.advanced-options .form-grid { padding: 12px; }
.query-summary { border-left: 3px solid var(--accent); background: var(--accent-soft); color: #315a43; padding: 10px 12px; font-size: 12px; font-weight: 700; }
.history-submit { min-height: 46px; }
.result-panel { min-width: 0; }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
th, td { padding: 10px 11px; border-bottom: 1px solid var(--line); text-align: left; }
th { position: sticky; top: 0; z-index: 1; background: #edf2ef; color: #465049; font-size: 11px; }
tbody tr:hover { background: #f7faf8; }
tbody tr:last-child td { border-bottom: 0; }
.status-label { font-weight: 750; }
.status-label.success { color: var(--ok); }
.status-label.failed { color: var(--bad); }

.toolbar-form { display: grid; grid-template-columns: 150px minmax(260px, 1fr) 120px auto minmax(120px, .5fr); gap: 10px; align-items: end; margin-bottom: 18px; }
.news-list { display: grid; gap: 7px; }
.news-item { display: grid; grid-template-columns: 150px minmax(0, 1fr) 120px; gap: 14px; align-items: center; padding: 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel-alt); }
.news-item time, .news-item small { color: var(--muted); font-size: 11px; }
.news-item a { color: var(--ink); font-weight: 750; text-decoration: none; }
.news-item a:hover { color: var(--accent); text-decoration: underline; }
.guide-content { max-width: 980px; }
.guide-content > p:not(.eyebrow) { margin-top: 12px; color: var(--muted); }
.guide-content li { margin: 5px 0; }
.flow-row { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin: 20px 0; }
.flow-row span { border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel-alt); padding: 11px 14px; font-weight: 750; }
.flow-row b { color: var(--accent); }
pre { overflow: auto; border-radius: 6px; background: #17251e; color: #dbede2; padding: 18px; font-size: 12px; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 420px; border-radius: 7px; background: #183126; color: #fff; padding: 11px 14px; box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); pointer-events: none; transition: .18s ease; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 1180px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .rate-grid { grid-template-columns: repeat(4, 1fr); }
  .split-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .login-screen { padding: 16px; }
  .login-card { padding: 28px 22px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; min-height: auto; }
  .nav-list { grid-template-columns: repeat(2, 1fr); }
  .sidebar-footer { margin-top: 12px; }
  .main-content { padding: 18px 14px 30px; }
  .topbar { align-items: flex-start; gap: 12px; }
  .topbar-actions { align-items: flex-end; flex-direction: column-reverse; }
  .metric-grid, .diagnostic-grid { grid-template-columns: 1fr; }
  .rate-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .toolbar-form { grid-template-columns: 1fr; }
  .history-guide { align-items: stretch; flex-direction: column; gap: 8px; }
  .history-guide > b { display: none; }
  .field-picker-toolbar, .field-option-list { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .news-item { grid-template-columns: 1fr; gap: 5px; }
}
