:root {
  --bg-0: #eef3ff;
  --bg-1: #d9e5f8;
  --bg-2: #f7fbff;
  --ink: #102348;
  --ink-soft: #4d6393;
  --line: rgba(16, 35, 72, 0.14);
  --card: rgba(255, 255, 255, 0.88);
  --card-strong: rgba(255, 255, 255, 0.96);
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --accent: #1b245f;
  --accent-2: #0c8aa6;
  --danger: #c9413a;
  --warning: #b27a04;
  --ok: #157a4b;
  --status-bg: rgba(255, 255, 255, 0.84);
  --status-border: rgba(16, 35, 72, 0.18);
  --status-good-bg: rgba(21, 122, 75, 0.1);
  --status-good-border: rgba(21, 122, 75, 0.42);
  --status-good-text: #0f5c39;
  --status-ok-bg: rgba(21, 122, 75, 0.1);
  --status-ok-border: rgba(21, 122, 75, 0.42);
  --status-ok-text: #0f5c39;
  --status-warn-bg: rgba(178, 122, 4, 0.12);
  --status-warn-border: rgba(178, 122, 4, 0.46);
  --status-warn-text: #7a4f00;
  --status-err-bg: rgba(201, 65, 58, 0.12);
  --status-err-border: rgba(201, 65, 58, 0.48);
  --status-err-text: #922a24;
  --radius: 16px;
  --shadow: 0 20px 42px rgba(18, 37, 79, 0.14);
}

[data-theme="dark"] {
  --bg-0: #0d1422;
  --bg-1: #101a2c;
  --bg-2: #18243a;
  --ink: #e7eefc;
  --ink-soft: #9fb2da;
  --line: rgba(200, 215, 255, 0.14);
  --card: rgba(22, 31, 49, 0.84);
  --card-strong: rgba(22, 31, 49, 0.96);
  --surface: #1b273d;
  --surface-soft: #142036;
  --accent: #2c7abf;
  --accent-2: #15a5c6;
  --status-bg: rgba(23, 34, 54, 0.9);
  --status-border: rgba(166, 188, 235, 0.34);
  --status-good-bg: rgba(23, 111, 69, 0.34);
  --status-good-border: rgba(76, 200, 136, 0.52);
  --status-good-text: #d5f7e8;
  --status-ok-bg: rgba(23, 111, 69, 0.34);
  --status-ok-border: rgba(76, 200, 136, 0.52);
  --status-ok-text: #d5f7e8;
  --status-warn-bg: rgba(141, 101, 21, 0.36);
  --status-warn-border: rgba(236, 190, 94, 0.55);
  --status-warn-text: #fff1cb;
  --status-err-bg: rgba(132, 45, 45, 0.38);
  --status-err-border: rgba(241, 126, 126, 0.58);
  --status-err-text: #ffe2e2;
  --shadow: 0 20px 42px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top right, rgba(12, 138, 166, 0.08), transparent 36%),
    linear-gradient(145deg, var(--bg-0), var(--bg-1) 55%, var(--bg-2));
  min-height: 100vh;
  line-height: 1.5;
}

.bg-glow {
  position: fixed;
  border-radius: 999px;
  filter: blur(38px);
  pointer-events: none;
  opacity: 0.45;
  z-index: 0;
}

.glow-a {
  width: 250px;
  height: 250px;
  top: 30px;
  right: 10%;
  background: radial-gradient(circle at 35% 35%, #1094ab, transparent 70%);
}

.glow-b {
  width: 300px;
  height: 300px;
  left: 10%;
  bottom: 60px;
  background: radial-gradient(circle at 35% 35%, #355eb1, transparent 70%);
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: linear-gradient(170deg, var(--card-strong), var(--card));
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.brand-block {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  padding: 8px;
}

.brand-logo {
  display: block;
  width: 170px;
  max-height: 76px;
  max-width: 100%;
  object-fit: contain;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 10px;
  text-align: left;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
}

.nav-parent-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-parent-btn.active {
  background: rgba(27, 36, 95, 0.08);
  color: var(--ink);
  border-color: rgba(27, 36, 95, 0.18);
  box-shadow: none;
}

.nav-submenu {
  display: grid;
  gap: 6px;
  padding-left: 10px;
  margin-left: 10px;
  border-left: 1px solid rgba(27, 36, 95, 0.12);
}

.nav-sub-btn {
  padding: 9px 10px;
  font-size: 0.92rem;
}

.nav-caret {
  font-size: 0.92rem;
  color: var(--ink-soft);
  transition: transform 0.18s ease, color 0.18s ease;
}

.nav-parent-btn.expanded .nav-caret {
  transform: rotate(180deg);
  color: var(--accent-2);
}

.nav-btn-primary {
  position: relative;
  border-color: rgba(12, 138, 166, 0.28);
  background: linear-gradient(180deg, rgba(12, 138, 166, 0.08), rgba(27, 36, 95, 0.05));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.34), 0 10px 20px rgba(12, 138, 166, 0.08);
}

.nav-btn-primary::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 8px;
  border: 1px solid rgba(12, 138, 166, 0.18);
  pointer-events: none;
}

.nav-btn-primary:hover {
  border-color: rgba(12, 138, 166, 0.4);
  background: linear-gradient(180deg, rgba(12, 138, 166, 0.12), rgba(27, 36, 95, 0.08));
}

.nav-btn-primary.active {
  box-shadow: 0 10px 24px rgba(12, 138, 166, 0.24);
}

.nav-btn:hover {
  background: rgba(27, 36, 95, 0.08);
  border-color: rgba(27, 36, 95, 0.16);
}

.nav-btn.active {
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 8px 20px rgba(16, 38, 95, 0.3);
}

.side-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card-strong);
  padding: 10px;
  display: grid;
  gap: 6px;
}

.side-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.68rem;
  color: var(--ink-soft);
}

.side-main {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 800;
  word-break: break-word;
}

.side-sub {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.side-card code {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.sample-links {
  display: grid;
  gap: 4px;
  max-width: 100%;
  max-height: 132px;
  overflow: auto;
  padding-right: 3px;
}

.sample-links a {
  display: block;
  max-width: 100%;
  color: var(--accent-2);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sample-links a:hover {
  text-decoration: underline;
}

.main {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}

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

.top-actions .btn,
.top-actions .inline-check,
.top-actions #auth-user-label {
  white-space: nowrap;
}

h1 {
  margin: 0;
  font-size: clamp(1.4rem, 2.2vw, 2rem);
}

h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.muted {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.88rem;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

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

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--ink-soft);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 12px;
  background: linear-gradient(140deg, rgba(27, 36, 95, 0.12), rgba(12, 138, 166, 0.12));
  border: 1px solid rgba(27, 36, 95, 0.14);
  font-size: 0.77rem;
  font-weight: 700;
  color: var(--ink);
}

.pill.ghost {
  background: var(--surface);
}

.overview-card {
  padding: 16px;
  background:
    linear-gradient(140deg, color-mix(in srgb, var(--surface) 74%, transparent), color-mix(in srgb, var(--card-strong) 92%, transparent)),
    linear-gradient(120deg, rgba(27, 36, 95, 0.08), rgba(12, 138, 166, 0.1));
}

.overview-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.overview-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.overview-panel {
  border: 1px solid rgba(16, 35, 72, 0.12);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--surface-soft) 82%, transparent));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--surface) 55%, transparent);
  min-height: 132px;
}

.overview-panel h3 {
  margin: 0 0 8px;
  font-size: 1.06rem;
}

.overview-panel .muted {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

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

.grid.two {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid.two > label,
.stack > label {
  display: grid;
  gap: 6px;
  align-content: start;
  font-weight: 700;
}

.grid.two > label.full {
  grid-column: 1 / -1;
}

.grid.two > .report-visible-sections-field.full {
  grid-column: 1 / -1;
}

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

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

.row.space {
  justify-content: space-between;
}

.gap-sm {
  gap: 8px;
}

.btn,
input,
select,
textarea {
  font: inherit;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid rgba(16, 35, 72, 0.2);
  padding: 9px 10px;
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
}

.btn {
  cursor: pointer;
  border-color: transparent;
  color: #fff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
  user-select: none;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  box-shadow: none;
}

.btn:focus,
.btn:focus-visible,
input:focus,
input:focus-visible,
select:focus,
select:focus-visible,
textarea:focus,
textarea:focus-visible,
.metric-button:focus,
.metric-button:focus-visible {
  outline: none;
  border-color: rgba(23, 122, 178, 0.34);
  box-shadow: inset 0 0 0 1px rgba(23, 122, 178, 0.12);
}

.btn:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.btn.is-busy {
  filter: saturate(0.9);
}

.btn.ghost {
  color: var(--ink);
  background: var(--surface);
  border-color: rgba(16, 35, 72, 0.22);
}

.btn.ghost:hover {
  background: var(--surface-soft);
  box-shadow: none;
}

input[type="file"] {
  width: 100%;
  min-height: 46px;
  padding: 7px 10px;
}

input[type="file"]::file-selector-button {
  font: inherit;
  font-weight: 700;
  margin-right: 10px;
  min-height: 32px;
  padding: 6px 12px;
  border-radius: 9px;
  border: 1px solid rgba(16, 35, 72, 0.18);
  background: color-mix(in srgb, var(--surface-soft) 92%, transparent);
  color: var(--ink);
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  background: color-mix(in srgb, var(--surface-soft) 82%, transparent);
}

.btn.disabled,
a.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn.warn {
  background: var(--warning);
}

.btn.danger {
  background: var(--danger);
}

.btn.ok {
  background: var(--ok);
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.inline-check input {
  width: 16px;
  height: 16px;
}

.report-section-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.report-section-option {
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid rgba(16, 35, 72, 0.12);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}

.report-section-option span {
  display: grid;
  gap: 2px;
}

.report-section-option small {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
}

.summary-row-note {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.76rem;
  line-height: 1.4;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.filter-row > * {
  min-width: 150px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table-wrap.compact th,
.table-wrap.compact td {
  padding: 6px 8px;
  font-size: 0.78rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid rgba(16, 35, 72, 0.1);
  padding: 7px 6px;
  vertical-align: top;
}

th {
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.68rem;
}

.snapshot {
  display: grid;
  gap: 10px;
}

.snapshot .tenant-block {
  border: 1px solid rgba(16, 35, 72, 0.12);
  border-radius: 12px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.12);
}

.snapshot .tenant-title {
  font-weight: 800;
  margin-bottom: 4px;
}

.snapshot .path {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.wizard-list {
  display: grid;
  gap: 12px;
}

.wizard-item {
  border: 1px solid rgba(16, 35, 72, 0.16);
  border-radius: 14px;
  padding: 10px;
  background: color-mix(in srgb, var(--surface) 26%, transparent);
  display: grid;
  gap: 10px;
}

.wizard-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
  display: grid;
  gap: 10px;
}

.wizard-fieldset:disabled {
  opacity: 0.82;
}

.status-box {
  margin-top: 8px;
  border: 1px solid var(--status-border);
  border-radius: 10px;
  background: var(--status-bg);
  color: var(--ink);
  padding: 8px 10px;
}

.status-box.good {
  border-color: var(--status-good-border);
  background: var(--status-good-bg);
  color: var(--status-good-text);
}

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

.status-box.warning {
  border-color: var(--status-warn-border);
  background: var(--status-warn-bg);
  color: var(--status-warn-text);
}

.status-box.success {
  border-color: var(--status-ok-border);
  background: var(--status-ok-bg);
  color: var(--status-ok-text);
}

.status-box.err {
  border-color: var(--status-err-border);
  background: var(--status-err-bg);
  color: var(--status-err-text);
}

.status-box.muted {
  color: var(--ink-soft);
}

.wizard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wizard-title {
  margin: 0;
  font-size: 0.95rem;
}

.required-blocker {
  border: 1px dashed rgba(201, 65, 58, 0.45);
  border-radius: 11px;
  background: rgba(201, 65, 58, 0.06);
  padding: 8px;
}

.required-blocker h4 {
  margin: 0 0 6px;
  font-size: 0.83rem;
}

.required-blocker p {
  margin: 4px 0;
  font-size: 0.82rem;
}

.template-bar {
  border: 1px solid rgba(16, 35, 72, 0.16);
  border-radius: 11px;
  padding: 8px;
  background: color-mix(in srgb, var(--surface) 18%, transparent);
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 9px;
  border: 1px solid transparent;
  line-height: 1.1;
  white-space: nowrap;
}

.badge.good {
  color: #0d6f42;
  background: rgba(21, 122, 75, 0.12);
  border-color: rgba(21, 122, 75, 0.3);
}

.badge.warn {
  color: #9e6500;
  background: rgba(178, 122, 4, 0.14);
  border-color: rgba(178, 122, 4, 0.3);
}

.badge.err {
  color: #a52b25;
  background: rgba(201, 65, 58, 0.14);
  border-color: rgba(201, 65, 58, 0.32);
}

.mapping-grid {
  display: grid;
  gap: 7px;
  grid-template-columns: minmax(180px, 220px) minmax(150px, 1fr);
}

.mapping-grid label {
  font-size: 0.84rem;
}

.mapping-grid .field-name {
  color: var(--ink-soft);
  font-weight: 700;
  padding-top: 8px;
}

.pdf-canvas-wrap {
  position: relative;
  width: 100%;
  max-width: 860px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  overflow: auto;
}

#visual-pdf-canvas,
#visual-overlay-canvas {
  display: block;
  width: 100%;
}

#visual-overlay-canvas {
  position: absolute;
  inset: 0;
  cursor: crosshair;
}

.visual-mapping-grid {
  display: grid;
  gap: 8px;
}

.visual-map-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(170px, 1fr);
  gap: 8px;
  align-items: center;
}

.code-box,
.log-output {
  margin: 0;
  border: 1px solid rgba(16, 35, 72, 0.2);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 8px;
  min-height: 80px;
  max-height: 220px;
  overflow: auto;
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 0.75rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.metric-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
}

.metric {
  border: 1px solid rgba(16, 35, 72, 0.14);
  border-radius: 11px;
  padding: 9px 10px;
  background: color-mix(in srgb, var(--surface) 18%, transparent);
  display: grid;
  grid-template-rows: auto minmax(1.6em, auto);
  align-content: start;
  gap: 6px;
  min-height: 86px;
}

.metric .label {
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.66rem;
  line-height: 1.22;
  min-height: 2.4em;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}

.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(16, 35, 72, 0.24);
  font-size: 0.62rem;
  line-height: 1;
  font-style: normal;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.72);
  cursor: pointer;
  flex: 0 0 auto;
}

.info-tip:hover,
.info-tip:focus-visible,
.info-tip.is-open {
  border-color: rgba(22, 105, 164, 0.4);
  color: var(--accent-2);
  background: rgba(255, 255, 255, 0.92);
}

.info-tip::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: min(280px, 42vw);
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(8, 18, 44, 0.96);
  color: #fff;
  text-transform: none;
  letter-spacing: normal;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 12px 24px rgba(8, 18, 44, 0.2);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}

.info-tip::before {
  content: "";
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 10px;
  height: 10px;
  background: rgba(8, 18, 44, 0.96);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.info-tip:hover::after,
.info-tip:hover::before,
.info-tip:focus-visible::after,
.info-tip:focus-visible::before,
.info-tip.is-open::after,
.info-tip.is-open::before {
  opacity: 1;
}

.metric .value {
  margin-top: 0;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.18;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric .value.numeric {
  font-variant-numeric: tabular-nums;
}

.reason-chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(16, 35, 72, 0.2);
  border-radius: 999px;
  padding: 4px 9px;
  background: color-mix(in srgb, var(--surface) 18%, transparent);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.exception-type-cell,
.exception-action-cell,
.exception-lifecycle-cell,
.exception-details-cell {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.exception-type-label,
.exception-details-title {
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.exception-type-code,
.exception-action-note,
.exception-lifecycle-note,
.exception-details-note {
  color: var(--ink-soft);
  font-size: 0.76rem;
  line-height: 1.35;
}

.exception-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.exception-actions .btn {
  padding: 7px 10px;
}

.exception-guide {
  margin: 12px 0;
  line-height: 1.45;
}

.exception-details-history {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

.quarantine-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, max-content));
  gap: 8px;
  align-items: start;
  min-width: 460px;
}

#quarantine-table td:last-child {
  min-width: 480px;
}

.quarantine-actions .btn,
.quarantine-actions a.btn {
  justify-self: start;
  white-space: nowrap;
}

.billing-admin-note {
  margin-top: 8px;
}

.metric-button {
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--surface-soft) 90%, transparent));
  border: 1px solid rgba(16, 35, 72, 0.12);
  color: var(--ink);
  user-select: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.metric-button:hover {
  border-color: rgba(23, 122, 178, 0.22);
  box-shadow: inset 0 0 0 1px rgba(23, 122, 178, 0.08);
}

.metric-shortcut {
  position: relative;
  overflow: hidden;
}

.metric-link-hint {
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  flex: 0 0 auto;
}

.metric-button .label,
.metric-button .value {
  color: inherit;
}

.reason-chip-button {
  cursor: pointer;
  border: 1px solid rgba(16, 35, 72, 0.12);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  user-select: none;
}

.reason-chip-button:hover {
  border-color: rgba(23, 122, 178, 0.28);
}

.summary-drilldown-panel {
  margin-top: 10px;
}

.summary-drilldown-panel h3 {
  margin: 0 0 4px;
}

.billing-admin-row-cell {
  color: var(--ink-soft);
  font-size: 0.84rem;
}

.billing-admin-editor {
  margin-top: 10px;
  display: grid;
  gap: 8px;
  border: 1px solid rgba(16, 35, 72, 0.14);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 66%, transparent);
  padding: 10px;
}

.billing-admin-editor summary {
  cursor: pointer;
  font-weight: 800;
  color: var(--ink);
}

.billing-admin-editor-body {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.billing-admin-editor-title {
  font-weight: 800;
  color: var(--ink);
}

.billing-admin-editor-note {
  font-size: 12px;
  color: var(--ink-soft);
}

.billing-admin-editor label {
  display: grid;
  gap: 4px;
  font-size: 12px;
  color: var(--ink-soft);
}

.billing-admin-editor textarea,
.billing-admin-editor input[type="number"],
.billing-admin-editor input[type="text"] {
  width: 100%;
}

#exceptions-table td:nth-child(1) {
  min-width: 160px;
}

#exceptions-table td:nth-child(3) {
  min-width: 200px;
}

#exceptions-table td:nth-child(4) {
  min-width: 190px;
}

#exceptions-table td:nth-child(5) {
  min-width: 320px;
}

@media (max-width: 1200px) {
  .metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  }

  #exceptions-table td:nth-child(5) {
    min-width: 240px;
  }
}

@media (max-width: 900px) {
  .info-tip::after {
    width: min(240px, 72vw);
    left: auto;
    right: 0;
    transform: none;
  }

  .info-tip::before {
    left: auto;
    right: 10px;
    transform: rotate(45deg);
  }
}

#run-fee-details {
  margin-top: 10px;
}

.collapse-shell {
  margin-top: 10px;
  border: 1px solid rgba(16, 35, 72, 0.12);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
  overflow: hidden;
}

.collapse-shell > summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 14px;
  font-weight: 800;
  color: var(--ink);
}

.collapse-shell > summary::-webkit-details-marker {
  display: none;
}

.collapse-shell > :not(summary) {
  padding: 0 14px 14px;
}

.card.subtle {
  border-style: dashed;
  background: color-mix(in srgb, var(--surface) 10%, transparent);
}

.wizard-hero {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1px solid rgba(16, 35, 72, 0.12);
  border-radius: 12px;
  padding: 10px 12px;
  background: color-mix(in srgb, var(--surface) 58%, transparent);
}

.wizard-hero.ready {
  border-color: rgba(21, 122, 75, 0.28);
  background: color-mix(in srgb, var(--status-good-bg) 88%, var(--surface));
}

.wizard-hero.attention {
  border-color: rgba(178, 122, 4, 0.28);
  background: color-mix(in srgb, var(--status-warn-bg) 88%, var(--surface));
}

.wizard-inline-alert {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(201, 65, 58, 0.12);
  color: var(--danger);
  font-weight: 700;
  white-space: nowrap;
}

.wizard-section {
  border: 1px solid rgba(16, 35, 72, 0.14);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 44%, transparent);
  overflow: hidden;
}

.wizard-section > summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  padding: 10px 12px;
  font-weight: 800;
  color: var(--ink);
}

.wizard-section > summary::-webkit-details-marker {
  display: none;
}

.wizard-section-body {
  padding: 0 12px 12px;
  display: grid;
  gap: 10px;
}

.wizard-section.compact .wizard-section-body {
  gap: 8px;
}

.wizard-parent-shell {
  border: 1px solid rgba(16, 35, 72, 0.12);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 54%, transparent);
  overflow: hidden;
}

.wizard-parent-shell > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px;
  font-weight: 800;
  color: var(--ink);
}

.wizard-parent-shell > summary::-webkit-details-marker {
  display: none;
}

.wizard-parent-note {
  color: var(--ink-soft);
  font-size: 0.82rem;
  font-weight: 600;
}

.wizard-parent-body {
  padding: 0 12px 12px;
  display: grid;
  gap: 10px;
}

.wizard-primary-actions {
  margin: 10px 0;
  flex-wrap: wrap;
}

.section-alert {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(201, 65, 58, 0.12);
  color: var(--danger);
  font-size: 0.74rem;
  font-weight: 800;
}

.summary-glance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
  grid-column: 1 / -1;
}

.summary-glance-card {
  border: 1px solid rgba(16, 35, 72, 0.12);
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--surface-soft) 86%, transparent));
  padding: 12px;
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.summary-glance-card h3 {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.summary-glance-graphic {
  width: 84px;
  height: 84px;
  display: grid;
  place-items: center;
}

.glance-donut {
  width: 84px;
  height: 84px;
}

body.simple-view .summary-drilldown-panel .table-wrap td:nth-child(4),
body.simple-view .summary-drilldown-panel .table-wrap th:nth-child(4) {
  min-width: 140px;
}

body.simple-view .reconcile-selection-card .grid.two {
  grid-template-columns: 1fr;
}

body.simple-view .reconcile-summary-card #run-summary-glance {
  margin-bottom: 6px;
}

body.simple-view #run-summary-metrics .metric-grid,
body.simple-view #run-summary-metrics {
  gap: 8px;
}

body.simple-view .reconcile-detail-card .table-wrap th:nth-child(4),
body.simple-view .reconcile-detail-card .table-wrap td:nth-child(4),
body.simple-view .reconcile-detail-card .table-wrap th:nth-child(5),
body.simple-view .reconcile-detail-card .table-wrap td:nth-child(5) {
  min-width: 120px;
}

[data-theme="dark"] .overview-card,
[data-theme="dark"] .overview-panel,
[data-theme="dark"] .metric-button,
[data-theme="dark"] .reason-chip-button,
[data-theme="dark"] .billing-admin-editor,
[data-theme="dark"] .summary-glance-card,
[data-theme="dark"] .wizard-section,
[data-theme="dark"] .wizard-hero,
[data-theme="dark"] .card.subtle {
  color: var(--ink);
}

[data-theme="dark"] .nav-parent-btn.active {
  background: rgba(44, 122, 191, 0.16);
  border-color: rgba(44, 122, 191, 0.28);
}

[data-theme="dark"] .nav-submenu {
  border-left-color: rgba(200, 215, 255, 0.16);
}

[data-theme="dark"] .nav-btn-primary {
  border-color: rgba(21, 165, 198, 0.34);
  background: linear-gradient(180deg, rgba(21, 165, 198, 0.16), rgba(44, 122, 191, 0.12));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 10px 24px rgba(21, 165, 198, 0.12);
}

[data-theme="dark"] .nav-btn-primary::after {
  border-color: rgba(21, 165, 198, 0.22);
}

[data-theme="dark"] .overview-panel,
[data-theme="dark"] .summary-glance-card,
[data-theme="dark"] .metric-button,
[data-theme="dark"] .reason-chip-button,
[data-theme="dark"] .billing-admin-editor,
[data-theme="dark"] .collapse-shell,
[data-theme="dark"] .wizard-parent-shell,
[data-theme="dark"] .wizard-item,
[data-theme="dark"] .template-bar,
[data-theme="dark"] .wizard-section,
[data-theme="dark"] .wizard-hero {
  border-color: rgba(200, 215, 255, 0.16);
  box-shadow: none;
}

[data-theme="dark"] .exception-actions .btn.ghost {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(127, 216, 239, 0.3);
  color: #eef8ff;
}

[data-theme="dark"] .exception-actions .btn.ghost:hover {
  background: rgba(127, 216, 239, 0.12);
  border-color: rgba(127, 216, 239, 0.4);
}

[data-theme="dark"] .exception-actions .btn {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

#quarantine-count-badges {
  margin: 6px 0 10px;
}

.timeline {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.timeline li {
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline li.done {
  color: var(--ok);
}

.timeline li.current {
  color: #0b5f81;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.tab-btn {
  border: 1px solid rgba(16, 35, 72, 0.18);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.active {
  border-color: transparent;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.log-card {
  margin-bottom: 0;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 18, 44, 0.42);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 16px;
}

body.privacy-locked .shell,
body.privacy-locked .bg-glow {
  filter: blur(10px);
  opacity: 0.28;
  pointer-events: none;
  user-select: none;
}

.modal-panel {
  width: min(980px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card-strong);
  box-shadow: var(--shadow);
  padding: 14px;
}

.modal-panel.wide {
  width: min(1180px, 96vw);
}

.modal-panel-wide {
  width: min(1180px, 96vw);
}

#auth-modal .modal-panel {
  width: min(760px, 100%);
}

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

.auth-modal-layout {
  display: grid;
  gap: 12px;
}

.auth-form-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 14px;
}

.auth-form-header h3 {
  margin-bottom: 4px;
}

#signup-plan-guidance-body {
  gap: 6px;
}

#signup-plan-guidance-body strong {
  color: var(--ink);
}

#signup-form-status {
  min-height: 2.8em;
}

.signup-card-iframe {
  min-height: 180px;
  margin-top: 6px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.signup-card-iframe iframe {
  width: 100%;
  border: 0;
}

#signup-card-status {
  min-height: 1.4em;
}

#signup-card-status.err {
  color: #b40000;
}

#demo-login-card {
  margin-top: 10px;
  box-shadow: none;
  background: var(--surface-soft);
}

.workflow-card {
  margin-bottom: 4px;
  padding: 10px 12px;
  height: fit-content;
}

.quick-create-card {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.hierarchy-select-form,
.quick-create-form {
  gap: 12px;
  align-content: start;
}

.hierarchy-select-form label,
.quick-create-form label {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.hierarchy-select-form label > span,
.quick-create-form label > span {
  color: var(--ink);
  font-weight: 700;
}

.hierarchy-select-form select,
.hierarchy-select-form input,
.quick-create-form input {
  width: 100%;
}

.hierarchy-select-actions {
  grid-column: 1 / -1;
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.hierarchy-select-actions .btn {
  width: 100%;
  min-width: 0;
}

.quick-create-form .btn {
  margin-top: 4px;
  width: 100%;
}

.upload-feed-grid {
  align-items: start;
  margin-bottom: 12px;
}

.upload-feed-card {
  min-height: 0;
}

.upload-feed-card form {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-content: start;
}

.upload-form-actions {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  padding-bottom: 10px;
}

.upload-form-actions .btn {
  width: 100%;
}

.upload-feed-card .guide-callout {
  min-height: 3.2em;
}

.run-progress-card {
  min-height: 0;
  overflow: visible;
}

.run-progress-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 352px);
  gap: 14px;
  align-items: start;
}

.run-progress-main {
  display: grid;
  gap: 10px;
  align-content: start;
  min-width: 0;
}

.run-progress-main #run-summary-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 0;
  align-items: stretch;
}

.run-progress-side {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(16, 35, 72, 0.12);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-soft) 82%, transparent);
  align-content: start;
  min-width: 0;
}

.run-progress-side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.run-progress-side-head h3 {
  margin: 0;
  font-size: 1rem;
}

.run-progress-side label {
  display: grid;
  gap: 6px;
}

.run-progress-side select,
.run-progress-side .btn {
  width: 100%;
  max-width: 100%;
}

.run-progress-side-head .btn {
  width: auto;
  min-width: 140px;
}

.run-progress-side-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.run-progress-side-actions .btn {
  min-width: 0;
}

.reconcile-form {
  gap: 10px;
  align-content: start;
}

.reconcile-form label {
  display: grid;
  grid-template-columns: minmax(118px, 150px) minmax(0, 200px);
  align-items: center;
  gap: 10px;
}

.reconcile-form label > span,
.reconcile-form .field-label {
  margin: 0;
  color: var(--ink);
  font-weight: 700;
}

.reconcile-form input,
.reconcile-form select {
  width: 100%;
}

.reconcile-form .btn {
  width: 100%;
  margin-top: 2px;
}

.user-create-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 14px;
  align-items: start;
}

.user-create-form label {
  display: grid;
  gap: 6px;
  align-content: start;
}

.user-create-form .user-create-global {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 32px;
}

.user-create-form .user-create-actions {
  grid-column: 1 / -1;
  margin-top: 4px;
  justify-content: flex-start;
}

.user-create-form .user-create-actions .btn {
  min-width: 144px;
}

#preflight-status,
#data-availability-widget {
  margin-top: 10px;
}

.plaid-period-grid {
  margin-top: 14px;
}

#plaid-items {
  margin-top: 12px;
}

.billing-addon-actions {
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.billing-addon-card {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(16, 35, 72, 0.14);
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 94%, transparent), color-mix(in srgb, var(--surface-soft) 88%, transparent));
}

.billing-addon-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.billing-addon-card h3 {
  margin: 0;
  font-size: 1rem;
}

.billing-addon-card p {
  margin: 4px 0 0;
}

.billing-addon-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.billing-addon-actions-row .btn {
  min-width: 180px;
}

.workflow-steps {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 4px;
  font-size: 0.82rem;
}

.demo-login-option {
  display: grid;
  gap: 4px;
}

.demo-role-desc {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

.demo-role-help summary {
  cursor: pointer;
  color: var(--accent-2);
  font-size: 0.82rem;
  font-weight: 700;
}

.demo-role-help p {
  margin: 8px 0 0;
  font-size: 0.8rem;
}

.mfa-qr-box {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  display: grid;
  place-items: center;
  padding: 12px;
}

.mfa-qr-box canvas,
.mfa-qr-box img {
  max-width: 100%;
}

#mfa-actions {
  margin-top: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

#mfa-post-enable-note {
  margin-top: 8px;
}

#mfa-status-box {
  padding: 12px 14px;
}

.checklist {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.checklist .btn.checklist-done {
  background: rgba(49, 167, 107, 0.14);
  border-color: rgba(49, 167, 107, 0.38);
  color: var(--ink);
}

.checklist .btn.checklist-pending {
  border-style: dashed;
}

.workflow-steps li.workflow-step-done {
  color: var(--accent);
  font-weight: 700;
}

.workflow-steps li.workflow-step-pending {
  color: var(--ink-soft);
}

.guide-callout {
  display: none;
  margin: 2px 0 0;
  font-size: 0.8rem;
  border: 1px dashed rgba(12, 138, 166, 0.5);
  border-radius: 8px;
  padding: 6px 8px;
  background: rgba(12, 138, 166, 0.08);
  color: var(--ink-soft);
}

body.guided-mode .guide-callout {
  display: block;
}

body.tutorial-mode .guide-callout {
  display: block;
}

body.tutorial-mode .workflow-steps li {
  font-weight: 700;
}

code {
  font-family: "IBM Plex Mono", "Menlo", monospace;
  font-size: 0.74rem;
}

@media (max-width: 1024px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

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

  .top-actions {
    justify-content: flex-start;
  }

  .run-progress-shell {
    grid-template-columns: 1fr;
  }

  .run-progress-main #run-summary-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .main {
    padding: 10px;
  }

  .card {
    padding: 11px;
  }

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

  .hierarchy-select-form label,
  .quick-create-form label,
  .reconcile-form label {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .hierarchy-select-actions {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

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

  .user-create-form .user-create-global {
    padding-top: 0;
  }
}
