:root {
  --green-dark: #004c00;
  --green-mid: #9bc100;
  --orange: #cc8400;
  --bg: #f4f7f2;
  --card: #ffffff;
  --text: #1a2e1a;
  --muted: #5a6b5a;
  --border: #d8e3d4;
  --accent: #2677f2;
  --layout-max: 1760px;
  --layout-gutter: 1.5rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(180deg, #eef5ea 0%, var(--bg) 240px);
  color: var(--text);
}

.page-shell {
  width: min(var(--layout-max), calc(100% - 2 * var(--layout-gutter)));
  margin-inline: auto;
}

header {
  border-bottom: 1px solid var(--border);
  background: var(--card);
  padding-block: 1.25rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo {
  height: 56px;
  width: auto;
  object-fit: contain;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
  color: var(--green-dark);
}

header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

main {
  padding: 1.5rem 0 2rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 8px rgba(0, 76, 0, 0.05);
}

.card h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

input[type="file"] {
  width: 100%;
}

button,
.btn {
  appearance: none;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--green-dark);
  color: white;
}

button.secondary {
  background: #e8efe5;
  color: var(--green-dark);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.hidden {
  display: none !important;
}

.error {
  color: #b70000;
  margin-top: 0.75rem;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(20, 30, 20, 0.45);
}

.dialog-card {
  width: min(100%, 480px);
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  background: white;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.dialog-card h3 {
  margin: 0 0 0.75rem;
}

.dialog-card p {
  margin: 0;
  line-height: 1.5;
  white-space: pre-wrap;
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
}

.slider-group,
.variable-nav-group {
  flex: 1;
  min-width: 220px;
}

.variable-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.variable-nav select {
  flex: 1;
  min-width: 160px;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: white;
}

.slider-group input[type="range"] {
  width: 100%;
}

.variable-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 0.5rem;
}

.variable-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.variable-item select {
  min-width: 140px;
}

.plots {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

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

.plot-box img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: white;
}

.plot-box h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.plot-box-full {
  grid-column: 1 / -1;
  margin-top: 0.25rem;
}

.effect-size-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.effect-size-legend {
  margin-bottom: 0.85rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafcf9;
}

.effect-size-legend-title {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.effect-size-legend-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.35rem 1rem;
}

.effect-size-legend-item {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  font-size: 0.78rem;
  line-height: 1.35;
}

.effect-size-swatch {
  flex: 0 0 0.75rem;
  width: 0.75rem;
  height: 0.75rem;
  margin-top: 0.15rem;
  border-radius: 2px;
}

.effect-size-legend-id {
  flex: 0 0 auto;
  min-width: 1rem;
  font-weight: 700;
}

.effect-size-legend-label {
  color: var(--text);
  white-space: pre-line;
}

@media (max-width: 960px) {
  .effect-size-grid {
    grid-template-columns: 1fr;
  }
}

.effect-size-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem 0.75rem;
  background: white;
}

.effect-size-item.is-active {
  border-color: var(--green-dark);
  box-shadow: 0 0 0 2px rgba(0, 76, 0, 0.12);
}

.effect-size-item h4 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.effect-size-chart-wrap {
  position: relative;
  width: 100%;
  height: 260px;
}

.effect-size-chart {
  width: 100%;
  height: 100%;
}

.effect-size-empty-message {
  position: absolute;
  left: 58%;
  top: 42%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 0.15rem 0.35rem;
  color: #666;
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: center;
  pointer-events: none;
  z-index: 2;
}

.plot-hint {
  margin: 0 0 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.plot-chart {
  width: 100%;
  height: 420px;
  min-height: 280px;
}

#diagnose-text {
  white-space: pre-wrap;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  background: #f8fbf7;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  max-height: 420px;
  overflow: auto;
  margin-top: 1rem;
}

.recap-table-wrap {
  margin-top: 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafcf9;
}

.recap-table {
  width: 100%;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  line-height: 1.45;
}

.recap-table th,
.recap-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.recap-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef5ea;
  font-weight: 600;
  white-space: nowrap;
}

.recap-table th:first-child,
.recap-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  min-width: 7.5rem;
  white-space: nowrap;
  background: #f4f7f2;
  border-right: 1px solid var(--border);
}

.recap-table th:first-child {
  z-index: 3;
  background: #eef5ea;
}

.recap-table tbody tr:nth-child(even) td {
  background: #fafcf9;
}

.recap-table tbody tr:nth-child(even) td:first-child {
  background: #f0f4ee;
}

.recap-table tbody tr:hover td {
  background: #eef5ea;
}

.recap-table tbody tr:hover td:first-child {
  background: #e6efe3;
}

.recap-table td:not(:first-child) {
  min-width: 10rem;
  max-width: 22rem;
  word-break: break-word;
}

.status {
  color: var(--muted);
  font-size: 0.9rem;
}

.export-job {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbf7;
}

.slider-group input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.export-notice {
  margin-top: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: #eef5ea;
  border: 1px solid #c8dcc0;
  color: var(--muted);
  font-size: 0.9rem;
}

.export-job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 0.65rem;
}

.progress-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: #e3ece0;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--green-dark), var(--green-mid));
  transition: width 0.3s ease;
}
