:root {
  --bg: #f3f5f6;
  --panel: #ffffff;
  --text: #1c252c;
  --muted: #65717c;
  --line: #d7dee4;
  --line-strong: #aab5be;
  --nav: #20282f;
  --nav-soft: #2c363f;
  --focus: #315f7d;
  --pass: #13795b;
  --pass-bg: #e5f4ee;
  --warn: #9a5b00;
  --warn-bg: #fff0cc;
  --fail: #b42318;
  --fail-bg: #fee4e2;
  --draft: #4e5b66;
  --draft-bg: #edf1f4;
  --review: #23607e;
  --review-bg: #e4f0f6;
  --locked: #5c4774;
  --locked-bg: #efe8f6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
.button-link,
.file-button,
input,
select,
textarea {
  font: inherit;
}

button,
.button-link,
.file-button {
  max-width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  text-decoration: none;
  white-space: nowrap;
  overflow-wrap: anywhere;
}

button:hover,
.button-link:hover,
.file-button:hover {
  border-color: var(--line-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

button:focus,
.button-link:focus,
.file-button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.primary {
  background: #263238;
  border-color: #263238;
  color: #fff;
}

h1,
h2,
h3,
p,
dl,
dd {
  margin: 0;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 22px;
}

h3 {
  font-size: 16px;
}

.hidden {
  display: none !important;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  padding: 8px 10px;
}

textarea {
  min-height: 360px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 16px;
  min-height: 100vh;
  padding: 18px;
  color: #e8edf1;
  background: var(--nav);
}

.brand .eyebrow {
  color: #aebbc6;
}

.nav {
  display: grid;
  gap: 6px;
  align-content: start;
}

.nav-item {
  justify-content: flex-start;
  border-color: transparent;
  background: transparent;
  color: #d8e0e7;
}

.nav-item:hover,
.nav-item.is-active {
  background: var(--nav-soft);
  border-color: #3f4c57;
}

.license-box {
  display: grid;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid #3f4c57;
  color: #c1cbd4;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.main {
  min-width: 0;
  max-width: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.userbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.role-chip,
.status-chip,
.workflow-chip,
.decision {
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.role-chip {
  padding: 6px 9px;
  color: #315f7d;
  background: #e3eef5;
}

.view {
  min-width: 0;
  max-width: 100%;
  overflow-x: clip;
  padding: 18px;
}

.panel,
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  min-width: 0;
  max-width: 100%;
  padding: 16px;
}

.panel.narrow {
  max-width: 560px;
}

.panel-head,
.form-row,
.actions,
.detail-actions,
.workflow-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.form-row.end {
  justify-content: flex-end;
  margin-top: 12px;
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric-grid.workflow-grid {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
}

.metric {
  min-height: 94px;
  padding: 16px;
  display: grid;
  align-content: center;
  gap: 8px;
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  font-size: 30px;
}

.metric.pass strong {
  color: var(--pass);
}

.metric.warn strong {
  color: var(--warn);
}

.metric.fail strong {
  color: var(--fail);
}

.metric.workflow-draft strong {
  color: var(--draft);
}

.metric.workflow-review strong {
  color: var(--review);
}

.metric.workflow-approved strong {
  color: var(--pass);
}

.metric.workflow-rejected strong {
  color: var(--fail);
}

.metric.workflow-locked strong {
  color: var(--locked);
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
}

.ai-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(0, 1.05fr);
  gap: 16px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.55fr) minmax(0, 1.45fr);
  gap: 16px;
}

.mapping-layout {
  display: grid;
  grid-template-columns: minmax(310px, 0.42fr) minmax(0, 1.58fr);
  gap: 16px;
}

.mapping-workbench {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(0, 1.08fr);
  gap: 16px;
  margin-top: 16px;
}

.wide-panel {
  grid-column: 1 / -1;
}

.compact-list,
.session-table,
.user-table,
.service-account-table,
.mapping-profile-list,
.mapping-preview-cards {
  display: grid;
  gap: 8px;
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) repeat(5, minmax(120px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 0 0 12px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.filter-panel button {
  min-height: 36px;
}

.list-summary {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 10px;
}

.row-button,
.user-row {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(160px, 1fr) minmax(154px, auto);
  gap: 10px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.row-button > *,
.user-row > *,
.service-account-row > *,
.mapping-profile-button > *,
.package-item > * {
  min-width: 0;
}

.row-button.is-active {
  border-color: var(--focus);
  box-shadow: inset 3px 0 0 var(--focus);
}

.mapping-profile-button {
  width: 100%;
  min-height: 74px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.mapping-profile-button.is-active {
  border-color: var(--focus);
  box-shadow: inset 3px 0 0 var(--focus);
}

.mapping-profile-button .row-risk {
  grid-column: 1 / -1;
}

.row-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.row-meta {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.row-risk {
  color: var(--review);
  font-size: 12px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.row-badges,
.detail-badges {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.status-chip,
.workflow-chip,
.decision {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  padding: 7px 9px;
}

.decision {
  min-width: 76px;
}

.status-pass {
  background: var(--pass-bg);
  color: var(--pass);
}

.status-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.status-fail {
  background: var(--fail-bg);
  color: var(--fail);
}

.status-draft {
  background: var(--draft-bg);
  color: var(--draft);
}

.status-review {
  background: var(--review-bg);
  color: var(--review);
}

.status-approved {
  background: var(--pass-bg);
  color: var(--pass);
}

.status-rejected {
  background: var(--fail-bg);
  color: var(--fail);
}

.status-locked {
  background: var(--locked-bg);
  color: var(--locked);
}

.status-active,
.status-accepted {
  background: var(--pass-bg);
  color: var(--pass);
}

.status-inactive,
.status-duplicate {
  background: var(--draft-bg);
  color: var(--draft);
}

.status-required {
  background: var(--review-bg);
  color: var(--review);
}

.status-optional {
  background: var(--draft-bg);
  color: var(--draft);
}

.status-rejected {
  background: var(--fail-bg);
  color: var(--fail);
}

.detail-panel {
  min-width: 0;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.workflow-panel {
  display: grid;
  gap: 12px;
  padding: 14px 0;
  margin-bottom: 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.workflow-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

h4 {
  margin: 0;
  font-size: 14px;
}

.control-note {
  color: var(--muted);
  line-height: 1.45;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.workflow-actions {
  flex-wrap: wrap;
}

.workflow-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.workflow-form .wide {
  grid-column: 1 / -1;
}

.workflow-form textarea {
  min-height: 86px;
}

.detail-section {
  display: grid;
  gap: 10px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-width: 0;
  flex-wrap: wrap;
}

.section-status,
.muted-line {
  color: var(--muted);
  font-size: 12px;
}

.timeline {
  display: grid;
  gap: 8px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.timeline-marker {
  inline-size: 24px;
  block-size: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--review-bg);
  color: var(--review);
  font-size: 12px;
  font-weight: 700;
}

.timeline-item p,
.timeline-item span,
.timeline-item em,
.remediation-item p,
.package-item p {
  margin: 0;
  line-height: 1.45;
}

.timeline-item span,
.timeline-item em {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.timeline-item em {
  margin-top: 4px;
  font-style: normal;
}

.remediation-list,
.package-list {
  display: grid;
  gap: 8px;
}

.remediation-item,
.empty-inline,
.package-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.remediation-item.status-warn {
  border-left: 4px solid var(--warn);
}

.remediation-item.status-fail {
  border-left: 4px solid var(--fail);
}

.remediation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.compact-dl {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.compact-dl div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
}

.empty-inline {
  color: var(--muted);
  line-height: 1.5;
}

.package-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.package-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
}

.package-item span {
  font-size: 12px;
  font-weight: 700;
}

.package-item p {
  grid-column: 1 / -1;
  color: var(--muted);
}

.package-ready span {
  color: var(--pass);
}

.package-pending span {
  color: var(--warn);
}

.package-attention span {
  color: var(--fail);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 14px 0;
  background: var(--line);
  border: 1px solid var(--line);
}

.summary-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-grid.single {
  grid-template-columns: 1fr;
}

.summary-grid div {
  background: #fff;
  padding: 12px;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 6px;
}

dd {
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.data-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  border-top: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.data-table th:nth-child(1),
.data-table td:nth-child(1) {
  width: 150px;
}

.data-table th:nth-child(2),
.data-table td:nth-child(2) {
  width: 92px;
}

.data-table th:nth-child(3),
.data-table td:nth-child(3) {
  width: 112px;
}

.empty-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.wide-input {
  margin-top: 14px;
}

.wide-input textarea {
  min-height: 230px;
}

.check-line {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.check-line input {
  inline-size: 18px;
  min-height: 18px;
}

.ai-output {
  min-height: 330px;
  max-height: 520px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.55;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.secret-output {
  min-height: 44px;
  margin: 14px 0 0;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #101820;
  color: #e7f2f3;
  border-radius: 8px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
}

.mapping-editor-panel {
  min-width: 0;
}

.mapping-table-wrap {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mapping-table th:nth-child(1),
.mapping-table td:nth-child(1) {
  width: 170px;
}

.mapping-table th:nth-child(2),
.mapping-table td:nth-child(2),
.mapping-table th:nth-child(3),
.mapping-table td:nth-child(3) {
  width: auto;
}

.mapping-table th:nth-child(4),
.mapping-table td:nth-child(4) {
  width: 104px;
}

.mapping-table input {
  min-height: 32px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.mapping-endpoint {
  margin-bottom: 0;
}

.mapping-preview-output {
  min-height: 240px;
  max-height: 430px;
  margin: 12px 0 0;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.mapping-preview-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.mapping-preview-card.status-pass {
  border-left: 4px solid var(--pass);
}

.mapping-preview-card.status-warn {
  border-left: 4px solid var(--warn);
}

.mapping-preview-card.status-fail {
  border-left: 4px solid var(--fail);
}

.form-status {
  color: var(--muted);
  min-height: 18px;
}

.control-banner {
  display: grid;
  gap: 6px;
  padding: 12px 0 14px;
  margin-bottom: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.control-banner strong {
  color: var(--text);
  font-size: 15px;
}

.control-banner span {
  color: var(--muted);
  line-height: 1.5;
}

.control-banner.compact {
  padding: 10px 0;
  margin: 12px 0 0;
}

.audit-integrity.status-ok {
  border-top-color: var(--pass);
  border-bottom-color: var(--pass);
}

.audit-integrity.status-ok strong {
  color: var(--pass);
}

.audit-integrity.status-fail {
  border-top-color: var(--fail);
  border-bottom-color: var(--fail);
}

.audit-integrity.status-fail strong {
  color: var(--fail);
}

.export-status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 14px;
  background: var(--line);
  border: 1px solid var(--line);
}

.export-status-strip div {
  display: grid;
  gap: 6px;
  padding: 12px;
  background: #fff;
}

.export-status-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.export-status-strip strong {
  font-size: 22px;
}

.storage-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.storage-metrics div {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 14px;
  background: #fff;
}

.storage-metrics span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.storage-metrics strong {
  font-size: 22px;
  overflow-wrap: anywhere;
}

#jsonFileInput,
#restoreFileInput {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.user-row {
  grid-template-columns:
    minmax(92px, 0.72fr)
    minmax(118px, 0.9fr)
    minmax(92px, 0.68fr)
    minmax(112px, 0.82fr)
    minmax(112px, 0.82fr)
    minmax(68px, 0.42fr)
    minmax(98px, 0.68fr)
    minmax(48px, auto);
}

.service-account-row {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(120px, 0.55fr) minmax(160px, 0.8fr) minmax(130px, 0.75fr) minmax(110px, 0.6fr) minmax(90px, auto) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.user-row input,
.user-row select,
.service-account-row input,
.service-account-row select {
  min-width: 0;
  min-height: 32px;
}

@media (max-width: 1120px) {
  .app-shell,
  .review-layout,
  .ai-layout,
  .admin-layout,
  .mapping-layout,
  .mapping-workbench,
  .metric-grid,
  .metric-grid.workflow-grid,
  .summary-grid,
  .summary-grid.two,
  .filter-panel,
  .workflow-form,
  .package-list,
  .export-status-strip,
  .storage-metrics {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .userbar {
    justify-content: flex-start;
  }

  .row-button,
  .user-row {
    grid-template-columns: 1fr;
  }

  .service-account-row {
    grid-template-columns: 1fr;
  }

  .mapping-profile-button {
    grid-template-columns: 1fr;
  }

  .row-badges,
  .detail-badges {
    justify-content: flex-start;
  }

  .workflow-head,
  .detail-head,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  button,
  .button-link,
  .file-button {
    white-space: normal;
    text-align: center;
  }

  .data-table {
    display: block;
    overflow-x: auto;
  }

  .data-table th,
  .data-table td {
    min-width: 104px;
  }

  .data-table th:nth-child(1),
  .data-table td:nth-child(1) {
    min-width: 132px;
  }

  .mapping-table th,
  .mapping-table td {
    min-width: 126px;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 13px;
  }

  h1,
  h2 {
    font-size: 20px;
  }

  .login-view,
  .view {
    padding: 12px;
  }

  .login-panel,
  .panel,
  .metric {
    border-radius: 7px;
    padding: 12px;
  }

  .topbar {
    min-height: auto;
    padding: 12px;
  }

  .sidebar {
    padding: 12px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
    min-height: 38px;
  }

  .userbar,
  .actions,
  .detail-actions,
  .workflow-actions,
  .form-row {
    width: 100%;
  }

  .userbar > *,
  .actions > *,
  .detail-actions > *,
  .workflow-actions > *,
  .form-row > * {
    flex: 1 1 auto;
  }

  .form-row.end {
    align-items: stretch;
    flex-direction: column;
  }

  .form-status {
    width: 100%;
  }

  textarea,
  .wide-input textarea {
    min-height: 220px;
  }
}
