:root {
  color-scheme: light;
  --ink: #17302b;
  --ink-soft: #526662;
  --surface: #ffffff;
  --surface-muted: #f4f8f6;
  --line: #dce8e2;
  --brand: #087b6c;
  --brand-dark: #075e54;
  --brand-pale: #e5f4ef;
  --warning: #9b5a00;
  --warning-pale: #fff4db;
  --danger: #bc3636;
  --danger-dark: #982525;
  --danger-pale: #fff0f0;
  --success: #197344;
  --success-pale: #e8f6ed;
  --shadow: 0 14px 36px rgba(28, 64, 53, 0.1);
  --radius: 16px;
  --radius-small: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #edf5f1;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 0%, rgba(50, 154, 130, 0.16), transparent 28rem),
    linear-gradient(135deg, #edf6f2 0%, #f9fbfa 52%, #edf4f2 100%);
  font-size: 15px;
  line-height: 1.45;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(8, 123, 108, 0.36);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 30px 0 48px;
}

.boot-view {
  display: grid;
  min-height: min(420px, 70vh);
  place-content: center;
  justify-items: center;
  gap: 14px;
  color: var(--ink-soft);
}

.spinner {
  display: inline-block;
  width: 22px;
  height: 22px;
  border: 3px solid rgba(8, 123, 108, 0.2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-small {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-view {
  display: grid;
  min-height: min(680px, calc(100vh - 80px));
  place-items: center;
}

.login-panel {
  width: min(100%, 430px);
  padding: 44px;
  border: 1px solid rgba(220, 232, 226, 0.9);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 24px;
  place-items: center;
  border-radius: 16px;
  color: #fff;
  background: linear-gradient(145deg, var(--brand), #11a890);
  box-shadow: 0 10px 20px rgba(8, 123, 108, 0.25);
  font-size: 26px;
  font-weight: 800;
}

.brand-mark-small {
  width: 42px;
  height: 42px;
  margin: 0;
  border-radius: 13px;
  font-size: 21px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.17;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h3 {
  margin-bottom: 4px;
  font-size: 16px;
}

.muted,
.login-footnote,
.form-message,
.backend-status p,
.choice-card small,
.action-card small,
.result-meta,
.report-meta {
  color: var(--ink-soft);
}

.muted {
  margin-bottom: 0;
}

.stack-form {
  display: grid;
  gap: 12px;
  margin-top: 28px;
}

.stack-form label {
  font-size: 14px;
  font-weight: 700;
}

.stack-form input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #bdd1c9;
  border-radius: var(--radius-small);
  color: var(--ink);
  background: #fff;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.stack-form input:hover {
  border-color: #91b8ac;
}

.stack-form input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(8, 123, 108, 0.12);
  outline: 0;
}

.form-message {
  min-height: 1.35em;
  margin: -2px 0 0;
  font-size: 13px;
}

.form-message.error {
  color: var(--danger);
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.15;
  transition: transform 120ms ease, background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.button:not(:disabled):hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.52;
}

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

.button-primary:not(:disabled):hover {
  background: var(--brand-dark);
}

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

.button-danger:not(:disabled):hover {
  background: var(--danger-dark);
}

.button-quiet {
  border-color: #c7d8d1;
  color: var(--ink);
  background: #fff;
}

.button-quiet:not(:disabled):hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-pale);
}

.button-wide {
  width: 100%;
  margin-top: 4px;
}

.login-footnote {
  margin: 28px 0 0;
  font-size: 12px;
  text-align: center;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.brand-lockup,
.topbar-actions,
.inline-actions,
.panel-heading,
.selection-toolbar,
.switch-row,
.modal-heading,
.modal-actions,
.result-heading,
.report-item,
.produced-report {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 12px;
}

.brand-lockup h1 {
  margin: 0;
  font-size: 23px;
}

.brand-lockup .eyebrow {
  margin-bottom: 2px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.session-notice {
  margin: -4px 0 18px;
  padding: 10px 12px;
  border: 1px solid #efd397;
  border-radius: var(--radius-small);
  color: #714500;
  background: var(--warning-pale);
  font-size: 14px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(270px, 0.7fr) minmax(0, 1.6fr);
  align-items: start;
  gap: 22px;
}

.control-column,
.content-column {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 21px;
  border: 1px solid rgba(211, 226, 218, 0.95);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 5px 18px rgba(30, 72, 59, 0.055);
}

.panel-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.compact-heading {
  margin-bottom: 14px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #c9dad3;
  border-radius: 9px;
  color: var(--brand-dark);
  background: #fff;
  font-size: 20px;
  line-height: 1;
}

.icon-button:not(:disabled):hover {
  border-color: var(--brand);
  background: var(--brand-pale);
}

.backend-status {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-height: 49px;
}

.backend-status strong {
  display: block;
  margin-top: 1px;
  font-size: 14px;
}

.backend-status p {
  margin: 2px 0 0;
  font-size: 13px;
}

.status-dot {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: 50%;
}

.status-dot-neutral {
  background: #93a9a1;
}

.status-dot-ready {
  background: #32a166;
  box-shadow: 0 0 0 4px rgba(50, 161, 102, 0.12);
}

.status-dot-busy {
  background: #d68a0b;
  box-shadow: 0 0 0 4px rgba(214, 138, 11, 0.12);
}

.status-dot-error {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(188, 54, 54, 0.1);
}

.scope-options {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
  background: #fff;
}

.choice-card:hover {
  border-color: #a4c6bb;
  background: #fbfefd;
}

.choice-card input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--brand);
}

.choice-card span {
  display: grid;
  gap: 1px;
}

.choice-card strong {
  font-size: 14px;
}

.choice-card small {
  font-size: 12px;
}

.unit-selection {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.selection-toolbar {
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.selection-toolbar .muted {
  font-size: 12px;
}

.inline-actions {
  flex: 0 0 auto;
  gap: 10px;
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--brand-dark);
  background: transparent;
  font-size: 12px;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.text-button:disabled {
  color: var(--ink-soft);
}

.unit-list {
  display: grid;
  max-height: 257px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-small);
}

.unit-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 7px 10px;
  border-bottom: 1px solid #edf3f0;
  background: #fff;
  font-size: 13px;
}

.unit-option:last-child {
  border-bottom: 0;
}

.unit-option:hover {
  background: #f5faf8;
}

.unit-option input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--brand);
}

.unit-loading,
.unit-empty {
  padding: 12px;
  color: var(--ink-soft);
  font-size: 13px;
}

.execution-mode {
  display: grid;
  gap: 15px;
}

.switch-row {
  justify-content: space-between;
  gap: 15px;
}

.switch-row span {
  display: grid;
  gap: 2px;
}

.switch-row strong {
  font-size: 14px;
}

.switch-row small {
  color: var(--ink-soft);
  font-size: 12px;
}

.switch-row input {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  margin: 0;
  appearance: none;
  border: 1px solid #a9c1b7;
  border-radius: 999px;
  background: #e0eae5;
  transition: background-color 140ms ease, border-color 140ms ease;
}

.switch-row input::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(20, 55, 44, 0.25);
  content: "";
  transition: transform 140ms ease;
}

.switch-row input:checked {
  border-color: var(--brand);
  background: var(--brand);
}

.switch-row input:checked::after {
  transform: translateX(18px);
}

.reset-switch-row {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.reset-switch-row strong {
  color: var(--danger-dark);
}

.reset-switch-row input:checked {
  border-color: var(--danger);
  background: var(--danger);
}

.actual-warning {
  margin: 0;
  padding: 9px 10px;
  border: 1px solid #efcf8b;
  border-radius: 8px;
  color: #724500;
  background: var(--warning-pale);
  font-size: 12px;
}

.action-panel {
  min-height: 264px;
}

.execution-state {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  color: #526662;
  background: #eef4f1;
  font-size: 12px;
  font-weight: 700;
}

.execution-state.is-running {
  color: #754b00;
  background: var(--warning-pale);
}

.execution-state.is-blocked {
  color: var(--danger-dark);
  background: var(--danger-pale);
}

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

.action-card {
  display: flex;
  min-height: 93px;
  align-items: center;
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  transition: transform 130ms ease, border-color 130ms ease, box-shadow 130ms ease, background-color 130ms ease;
}

.action-card:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.action-card:not(:disabled):hover {
  border-color: #7ab5a5;
  background: #fbfefd;
  box-shadow: 0 7px 14px rgba(26, 91, 72, 0.1);
  transform: translateY(-1px);
}

.action-card:disabled {
  opacity: 0.58;
}

.action-card > span:last-child {
  display: grid;
  gap: 3px;
}

.action-card strong {
  font-size: 14px;
}

.action-card small {
  font-size: 12px;
  line-height: 1.32;
}

.action-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
  color: var(--brand-dark);
  background: var(--brand-pale);
  font-size: 15px;
  font-weight: 850;
}

.result-panel {
  min-height: 182px;
}

.empty-result,
.running-result {
  display: flex;
  min-height: 138px;
  align-items: center;
  gap: 15px;
}

.empty-result h2,
.running-result h2 {
  margin-bottom: 5px;
}

.empty-result p,
.running-result p {
  max-width: 520px;
  margin-bottom: 0;
  color: var(--ink-soft);
}

.empty-icon {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  color: #69857b;
  background: #edf5f1;
  font-size: 21px;
}

.result-heading {
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 14px;
}

.result-heading h2 {
  margin-bottom: 5px;
}

.result-meta {
  margin-bottom: 0;
  font-size: 13px;
}

.result-badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.result-badge.success {
  color: var(--success);
  background: var(--success-pale);
}

.result-badge.error {
  color: var(--danger-dark);
  background: var(--danger-pale);
}

.result-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 9px;
  margin: 16px 0;
}

.metric {
  min-width: 0;
  padding: 10px;
  border: 1px solid #e3ede8;
  border-radius: 10px;
  background: #fbfdfc;
}

.metric span {
  display: block;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.metric strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-message {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-left: 3px solid var(--brand);
  color: #36534b;
  background: #f0f8f5;
  font-size: 13px;
}

.result-message.error {
  border-left-color: var(--danger);
  color: #7d3030;
  background: var(--danger-pale);
}

.produced-reports {
  display: grid;
  gap: 7px;
  margin: 15px 0;
}

.produced-reports h3 {
  margin: 0;
  font-size: 13px;
}

.produced-report {
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid #dfebe5;
  border-radius: 8px;
  background: #fbfdfc;
  font-size: 13px;
}

.produced-report a,
.report-download {
  flex: 0 0 auto;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 750;
  text-decoration: none;
}

.produced-report a:hover,
.report-download:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.result-details {
  margin-top: 14px;
  border-top: 1px solid var(--line);
}

.result-details summary {
  padding-top: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.result-details pre {
  max-height: 300px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 8px;
  color: #335047;
  background: #f2f6f4;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.reports-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.report-item {
  justify-content: space-between;
  gap: 16px;
  padding: 11px 0;
  border-bottom: 1px solid #e7efeb;
}

.report-item:last-child {
  border-bottom: 0;
}

.report-name {
  display: block;
  overflow: hidden;
  max-width: 520px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-meta {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 20;
  right: 18px;
  bottom: 18px;
  width: min(420px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid #bcd9ce;
  border-radius: 11px;
  color: #164e40;
  background: #effaf5;
  box-shadow: 0 14px 32px rgba(20, 64, 51, 0.18);
  font-size: 14px;
  font-weight: 650;
}

.toast.error {
  border-color: #edb8b8;
  color: #7e2929;
  background: #fff3f3;
}

.toast.warning {
  border-color: #edcf92;
  color: #744900;
  background: #fff7e7;
}

.modal {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(13, 40, 33, 0.52);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(100%, 470px);
  padding: 24px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 65px rgba(6, 39, 30, 0.32);
}

.modal-heading {
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-heading h2 {
  margin-bottom: 0;
}

.modal-description {
  margin: 16px 0 0;
  color: var(--ink-soft);
}

.modal-actions {
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.noscript {
  margin: 20px;
  padding: 14px;
  border-radius: 10px;
  color: #7e2929;
  background: #fff0f0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }

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

  .control-column .status-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 630px) {
  .app-shell {
    width: min(100% - 20px, 1240px);
    padding-top: 12px;
  }

  .login-panel {
    padding: 30px 23px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    margin-bottom: 17px;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .topbar-actions .button {
    flex: 1;
  }

  .control-column,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .action-card:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .panel {
    padding: 17px;
  }

  .report-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .report-name {
    max-width: calc(100vw - 76px);
  }

  .result-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .modal-card {
    padding: 20px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
