:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-2: #f0f4f1;
  --line: #d7ddd8;
  --line-strong: #aab6ad;
  --text: #1b2420;
  --muted: #69746f;
  --brand: #226b5a;
  --brand-2: #b75f36;
  --danger: #b4232b;
  --shadow: 0 12px 32px rgba(20, 34, 28, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 34px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  padding: 0 12px;
  color: #fff;
  background: var(--brand);
  cursor: pointer;
}

button:hover {
  filter: brightness(0.96);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  filter: grayscale(0.4);
}

button.ghost {
  color: var(--text);
  background: #fff;
  border-color: var(--line-strong);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

button.nav-item {
  width: 100%;
  color: var(--text);
  background: transparent;
  border-color: transparent;
  justify-content: flex-start;
}

button.nav-item.active {
  color: #fff;
  background: var(--brand);
}

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

input[readonly] {
  background: #f3f6f4;
  color: var(--muted);
}

textarea {
  resize: vertical;
  line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

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

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

h1 {
  font-size: 18px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 14px;
  margin-bottom: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.intro-band {
  display: block;
  padding: 10px 14px;
}

.intro-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfb 100%);
  box-shadow: var(--shadow);
  padding: 10px 12px;
}

.intro-card h2 {
  font-size: 15px;
}

.intro-card ol {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text);
  line-height: 1.45;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 20px;
}

.intro-card li + li {
  margin-top: 0;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.topbar-actions,
.button-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
}

.layout {
  display: grid;
  grid-template-columns: 156px minmax(0, 1fr) minmax(300px, 390px);
  gap: 14px;
  padding: 0 14px 14px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 76px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.workspace {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.config-band,
.panel,
.result-pane {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.config-band,
.panel {
  padding: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-head.compact {
  padding: 12px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

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

.more-settings {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.more-settings summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

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

.micro-note,
.help-block {
  margin-top: 12px;
  border: 1px solid #dbe5db;
  background: #f7faf7;
  border-radius: 6px;
  padding: 10px 12px;
  color: #4f5b55;
  font-size: 12px;
  line-height: 1.5;
}

.identity-map {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 12px;
}

.identity-map span {
  min-height: 38px;
  display: grid;
  align-content: center;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.tab-panel.active .identity-map span:not(:last-child)::after {
  content: ">";
  position: absolute;
  right: -8px;
  top: 50%;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
}

.grid {
  display: grid;
  gap: 14px;
}

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

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

.file-query-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

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

.entitlement-target {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(160px, 1fr) minmax(110px, 0.6fr) minmax(130px, 0.8fr);
  gap: 12px;
}

.entitlement-target.simplified {
  grid-template-columns: minmax(260px, 1.5fr) minmax(180px, 1fr) 110px;
}

.unit-field {
  max-width: 140px;
}

.entitlement-card {
  display: grid;
  align-content: start;
}

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

.entitlement-head h3 {
  margin-bottom: 5px;
}

.entitlement-head p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.tag {
  display: inline-grid;
  min-height: 24px;
  align-items: center;
  border: 1px solid #cddbd2;
  border-radius: 999px;
  padding: 0 9px;
  background: #edf7f1;
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
}

.tag.accent {
  border-color: #ead4c4;
  background: #fff5ed;
  color: var(--brand-2);
}

.entitlement-metrics span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.secondary-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.secondary-row span {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 7px 8px;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.secondary-row strong {
  color: var(--text);
  font-weight: 700;
}

.inline-hint {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.inline-hint.ok {
  border-color: #b9dac5;
  background: #f4fbf6;
  color: #20603d;
}

.inline-hint.warn {
  border-color: #ecd1a5;
  background: #fff9ef;
  color: #8a5a12;
}

.detail-box {
  display: grid;
  gap: 10px;
}

.detail-box .table-wrap {
  max-height: 360px;
}

.detail-box .empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 18px;
  color: var(--muted);
  background: #fff;
}

.env-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.env-group {
  grid-column: 1 / -1;
  margin-top: 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
}

.env-grid span,
.env-field {
  min-width: 0;
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
}

.env-grid strong,
.env-field strong {
  overflow-wrap: anywhere;
  font-size: 11px;
  color: var(--muted);
}

.env-grid em,
.env-field em {
  min-height: 18px;
  overflow-wrap: anywhere;
  font-style: normal;
  font-size: 12px;
  color: var(--muted);
}

.personal-auth-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.personal-upload-grid {
  margin-bottom: 12px;
}

.divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line);
}

.env-field input {
  width: 100%;
  min-height: 30px;
  padding: 4px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.env-field input:focus {
  outline: 2px solid rgba(34, 107, 90, 0.18);
  outline-offset: 3px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--text);
}

.checkline input {
  width: auto;
  min-height: 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: grid;
  gap: 14px;
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metric-row span {
  min-height: 40px;
  display: grid;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: var(--surface-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 8px;
  text-align: left;
  font-size: 12px;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-weight: 700;
}

td.empty {
  text-align: center;
  color: var(--muted);
  padding: 26px;
}

.path-button {
  color: var(--brand);
  background: transparent;
  border: 0;
  min-height: 0;
  padding: 0;
  text-align: left;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.row-actions button {
  min-height: 28px;
  padding: 0 8px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.subtle {
  margin-bottom: 10px;
}

.result-pane {
  position: sticky;
  top: 76px;
  overflow: hidden;
}

.result-meta {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  color: var(--muted);
  font-size: 12px;
}

.result-title {
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}

.result-summary {
  margin-top: 4px;
  color: var(--brand);
  line-height: 1.45;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 24, 20, 0.38);
}

.dialog-card {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 60px rgba(10, 20, 16, 0.22);
  padding: 14px;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.dialog-body {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.dialog-body div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}

.dialog-body span {
  color: var(--muted);
}

.dialog-body b {
  min-width: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.hidden {
  display: none !important;
}

#resultBox {
  margin: 0;
  padding: 12px;
  min-height: 540px;
  max-height: calc(100vh - 210px);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.5;
  background: #101815;
  color: #d6f4e5;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 132px minmax(0, 1fr);
  }

  .result-pane {
    grid-column: 2;
    position: static;
  }
}

@media (max-width: 820px) {
  .topbar,
  .layout {
    display: block;
  }

  .topbar-actions {
    margin-top: 10px;
  }

  .sidebar {
    position: static;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 12px;
  }

  .workspace,
  .result-pane {
    margin: 12px;
  }

  .config-grid,
  .grid.two,
  .form-grid,
  .file-query-grid,
  .file-query-grid.compact-grid,
  .more-grid,
  .intro-card ol,
  .env-grid,
  .identity-map,
  .entitlement-target,
  .entitlement-target.simplified,
  .personal-auth-grid,
  .secondary-row {
    grid-template-columns: 1fr;
  }

  .unit-field {
    max-width: none;
  }

  .tab-panel.active .identity-map span:not(:last-child)::after {
    content: "v";
    right: auto;
    left: 14px;
    top: auto;
    bottom: -12px;
    transform: none;
  }
}
