:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e1e6ef;
  --text: #1b2330;
  --muted: #5b6577;
  --primary: #2b6cb0;
  --primary-dark: #1f4f84;
  --accent: #38a169;
  --danger: #c53030;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.06);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: var(--primary);
}

.app-header {
  padding: 24px 32px 8px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.app-header .subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 20px;
  padding: 16px 32px 40px;
  align-items: start;
}

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 14px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-header h2 {
  margin: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  gap: 4px;
}

label .hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
}

input[type="number"],
input[type="text"],
select {
  font: inherit;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  width: 100%;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.table-wrap {
  overflow-x: auto;
}

.rows-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.rows-table th,
.rows-table td {
  padding: 6px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.rows-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  font-weight: 600;
}

.rows-table td input {
  padding: 6px 8px;
}

.rows-table td input.color-input {
  padding: 0;
  width: 40px;
  height: 28px;
  border-radius: 4px;
  cursor: pointer;
  background: #fff;
}

.rows-table td input.color-input::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.rows-table td input.color-input::-webkit-color-swatch {
  border: 1px solid var(--border);
  border-radius: 3px;
}

.rows-table tbody:empty::after {
  content: "No rows yet — click + Add above.";
  display: block;
  padding: 10px 8px;
  color: var(--muted);
  font-style: italic;
  font-size: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

.btn:hover {
  background: #f7f9fc;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border: 1px dashed var(--border);
  color: var(--primary);
  font-size: 12px;
  padding: 6px 10px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 4px 6px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.btn-icon:hover {
  color: var(--danger);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 4px;
}

.share-feedback {
  min-height: 1.2em;
  margin: 4px 0 0;
  color: var(--accent);
  font-size: 12px;
}

.share-feedback.error {
  color: var(--danger);
}

.results {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.fos-card {
  text-align: center;
}

.fos-value {
  font-size: 48px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--primary);
  line-height: 1.1;
  margin: 4px 0 6px;
}

.fos-value.safe {
  color: var(--accent);
}

.fos-value.unsafe {
  color: var(--danger);
}

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

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

.plot-card {
  min-width: 0;
  overflow: hidden;
}

.plot {
  width: 100%;
  min-height: 550px;
  max-width: 100%;
  overflow: hidden;
}

.plot .js-plotly-plot,
.plot .plot-container,
.plot .svg-container {
  max-width: 100% !important;
}

.plot:empty::before {
  content: "Plot will appear here after calculation.";
  display: block;
  padding: 80px 0;
  text-align: center;
  color: var(--muted);
  font-style: italic;
}
