:root {
  color-scheme: dark;
  --bg: #111827;
  --panel: #182235;
  --panel-soft: #202b40;
  --text: #eef5ff;
  --muted: #b9c7d9;
  --line: rgba(255, 255, 255, 0.11);
  --accent: #0ea5a8;
  --accent-strong: #14b8a6;
  --violet: #7c3aed;
  --warning: #f59e0b;
  --danger: #ef4444;
  --success: #22c55e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page-header,
.layout,
.table-section {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
}

.page-header {
  padding: 24px 0 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

a {color: #90EE90; text-decoration: none;}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.5rem, 3vw, 3rem);
  line-height: 1;
}

h2 {
  font-size: 1.12rem;
}

.page-header p {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: clamp(0.8rem, 1vw, 1rem);
}

.header-note,
.disclaimer,
.message {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.header-note {
  max-width: 330px;
  padding: 14px 16px;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 500px) 1fr;
  gap: 20px;
  align-items: start;
}

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

.form-panel {
  padding: 18px;
}

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

.field-grid {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

label {
  position: relative;
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 650;
}

.conditional-field {
  transition: opacity 160ms ease, transform 160ms ease;
}

.conditional-field.is-hidden {
  display: none;
}

.field-title {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  line-height: 1.25;
  font-size: clamp(0.8rem,0.8vw, 0.9rem);
}

.help-trigger {
  position: relative;
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 26px;
  min-width: 26px;
  height: 26px;
  min-height: 26px;
  border: 1px solid rgba(20, 184, 166, 0.65);
  border-radius: 999px;
  background: rgba(20, 184, 166, 0.12);
  color: #bff7ef;
  padding: 0;
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1;
}

.help-trigger::after {
  content: attr(data-help);
  position: absolute;
  z-index: 20;
  right: 0;
  bottom: calc(100% + 10px);
  width: min(320px, calc(100vw - 48px));
  border: 1px solid rgba(20, 184, 166, 0.55);
  border-radius: 8px;
  background: #07111f;
  color: var(--text);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
  padding: 12px 13px;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.help-trigger::before {
  content: "";
  position: absolute;
  z-index: 21;
  right: 8px;
  bottom: calc(100% + 4px);
  width: 12px;
  height: 12px;
  background: #07111f;
  border-right: 1px solid rgba(20, 184, 166, 0.55);
  border-bottom: 1px solid rgba(20, 184, 166, 0.55);
  opacity: 0;
  pointer-events: none;
  transform: rotate(45deg) translateY(6px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.help-trigger:hover::after,
.help-trigger:focus-visible::after,
.help-trigger.is-open::after,
.help-trigger:hover::before,
.help-trigger:focus-visible::before,
.help-trigger.is-open::before {
  opacity: 1;
  transform: translateY(0);
}

.help-trigger:hover::before,
.help-trigger:focus-visible::before,
.help-trigger.is-open::before {
  transform: rotate(45deg) translateY(0);
}

small {
  color: var(--muted);
  font-weight: 450;
  line-height: 1.35;
}

input,
select,
button,
.import-button {
  min-height: 44px;
  border-radius: 8px;
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #0f172a;
  color: var(--text);
  padding: 10px 12px;
}

input:focus,
select:focus {
  outline: 2px solid rgba(20, 184, 166, 0.45);
  border-color: var(--accent-strong);
}

.toggle-field {
  grid-template-columns: 22px 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #0f172a;
}

.toggle-field input {
  min-height: 22px;
}

.toggle-field small {
  grid-column: 2;
}

.toggle-field .field-title {
  justify-content: space-between;
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-start;
  margin-top: 18px;
}

button,
.import-button {
  border: 0;
  cursor: pointer;
  padding: 0 16px;
  font-weight: 750;
}

.primary-button {
  background: var(--accent-strong);
  color: #052e2b;
}

.ghost-button,
.import-button {
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--text);

}

.import-button {
  display: inline-flex;
  align-items: center;
}

.import-button input {
  display: none;
}

.results {
  display: grid;
  gap: 16px;
}

.disclaimer {
  padding: 14px 16px;
  color: var(--muted);
}

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

.message {
  padding: 12px 14px;
}

.message.info {
  border-color: rgba(14, 165, 168, 0.35);
}

.message.warning {
  border-color: rgba(245, 158, 11, 0.7);
  background: rgba(245, 158, 11, 0.12);
}

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

.metric {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(1.25rem, 2vw, 1.8rem);
  line-height: 1.1;
}

.status-green {
  border-color: rgba(34, 197, 94, 0.6);
}

.status-yellow {
  border-color: rgba(245, 158, 11, 0.8);
}

.status-red {
  border-color: rgba(239, 68, 68, 0.8);
}

.chart-panel {
  padding: 18px;
  min-width: 0;
}

.table-section {
  margin-top: 20px;
  margin-bottom: 28px;
}

.table-section h2 {
  margin-bottom: 12px;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 1040px) {
  .page-header,
  .layout {
    grid-template-columns: 1fr;
  }

  .header-note {
    max-width: none;
  }

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

@media (max-width: 620px) {
  .page-header,
  .layout,
  .table-section {
    width: min(100% - 20px, 1480px);
  }

  .page-header {
    padding-top: 24px;
  }

  h1 {
    font-size: 1.75rem;
  }

  .page-header p {
    font-size: 0.8rem;
  }

  .form-panel,
  .chart-panel {
    padding: 14px;
  }

  .field-grid {
    gap: 12px;
  }

  input,
  select {
    min-height: 48px;
    font-size: 16px;
  }

  .help-trigger {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
  }

  .help-trigger::after {
    right: -6px;
    width: min(300px, calc(100vw - 28px));
    font-size: 0.92rem;
  }

  .metric-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .metric {
    display: flex;
    min-height: 78px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
  }

  .metric strong {
    margin-top: 0;
    text-align: right;
  }

  .panel-head,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  button,
  .import-button {
    width: 100%;
    justify-content: center;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .actions .primary-button {
    grid-column: 1 / -1;
  }

  table {
    min-width: 680px;
  }

  th,
  td {
    padding: 10px 11px;
  }
}

@media (max-width: 420px) {
  .page-header,
  .layout,
  .table-section {
    width: min(100% - 16px, 1480px);
  }

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

  .metric {
    display: grid;
  }

  .metric strong {
    text-align: left;
  }
}
