:root {
  color-scheme: light;
  --bg: #e9eef3;
  --panel: #ffffff;
  --text: #18212b;
  --muted: #607080;
  --line: #dce3ea;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(24, 33, 43, .10);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
}

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

.control-panel {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 22px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  box-shadow: 6px 0 24px rgba(24, 33, 43, .05);
}

.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.brand span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.brand strong {
  font-size: 22px;
}

form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 6px;
  color: #344150;
  font-size: 13px;
  font-weight: 700;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  background: #fff;
  font: inherit;
}

textarea:focus,
input:focus,
select:focus {
  outline: 2px solid rgba(15, 118, 110, .18);
  border-color: var(--accent);
}

textarea {
  resize: vertical;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
}

.check-row input {
  width: auto;
}

.combo {
  position: relative;
}

.combo-list {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.combo-list li {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.combo-list li:hover,
.combo-list li.active {
  background: #eaf3f2;
}

.combo-list .combo-empty {
  color: var(--muted);
  cursor: default;
  background: none;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

button {
  border: 1px solid #cfd8e3;
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
}

button:hover:not(:disabled) {
  background: #f5f8fa;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.status {
  margin-top: 18px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 13px;
}

.status.error {
  color: var(--danger);
  border-color: #f0b8b3;
  background: #fff4f2;
}

.privacy {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* --- Login view --- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(15, 118, 110, .10), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 30px 28px;
  box-shadow: var(--shadow);
}

.auth-card .brand {
  margin-bottom: 14px;
}

.auth-intro {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 20px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 400;
  text-decoration: underline;
  padding: 4px;
  cursor: pointer;
}

.link-btn:hover:not(:disabled) {
  background: none;
  color: var(--text);
}

.mfa-setup {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: #344150;
}

.mfa-setup p {
  margin: 0;
  font-weight: 400;
}

.mfa-setup code {
  display: block;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  word-break: break-all;
}

.mfa-setup a {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
}

#login-submit {
  margin-top: 4px;
}

/* --- Logged-in user bar --- */
.user-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.user-meta {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.user-meta strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta span {
  color: var(--muted);
  font-size: 11px;
}

.user-bar button {
  padding: 7px 12px;
  font-size: 13px;
  flex-shrink: 0;
}

/* --- Part 1: configuration form --- */
.form-stage {
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 48px 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(15, 118, 110, .10), transparent 60%),
    var(--bg);
}

.form-card {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 26px 26px 28px;
  box-shadow: var(--shadow);
}

.form-head {
  margin-bottom: 18px;
}

.form-head .brand {
  margin-bottom: 14px;
}

.form-card .user-bar {
  margin-bottom: 0;
}

/* --- Part 2: tabbed report results --- */
.results-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.results-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 10px rgba(24, 33, 43, .05);
}

.results-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.results-kicker {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
}

.results-title strong {
  font-size: 15px;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.tab:hover:not(:disabled) {
  background: #f5f8fa;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.results-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
}

.results-actions button {
  padding: 8px 13px;
  font-size: 13px;
}

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

.results-status.error {
  color: var(--danger);
}

.results-content {
  flex: 1;
  padding: 28px;
}

.tab-panel {
  display: none;
}

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

.loading-note {
  max-width: 1180px;
  margin: 60px auto;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.loading-note.error {
  color: var(--danger);
}

#report-preview {
  max-width: 1180px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #d8e0e8;
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#report-preview .report {
  padding: 32px 36px 42px;
}

#report-preview:empty {
  display: none;
}

@media (max-width: 900px) {
  .results-bar {
    gap: 10px;
  }

  .results-actions {
    margin-left: 0;
  }

  .results-content {
    padding: 16px;
  }

  #report-preview .report {
    padding: 22px 18px 30px;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm 8mm 11mm;
  }

  .results-bar {
    display: none;
  }

  .results-content {
    padding: 0;
  }

  #report-preview {
    max-width: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  #report-preview .report {
    padding: 0;
  }
}
