* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.5;
  color: #1a1a2e;
  background: #f5f5f7;
  min-height: 100vh;
}

/* Header */
.header {
  background: white;
  padding: 1rem 2rem;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.125rem;
}

.subtitle {
  color: #666;
  font-size: 0.875rem;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  max-width: 1600px;
  margin: 0 auto;
}

.panel {
  padding: 1rem;
  height: calc(100vh - 70px);
  overflow-y: auto;
}

.panel-controls {
  background: #f5f5f7;
  border-right: 1px solid #e0e0e0;
}

.panel-results {
  background: white;
  display: flex;
  flex-direction: column;
}

.panel-results .card {
  flex: 1;
}

.panel-results footer {
  margin-top: auto;
}

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

  .panel {
    height: auto;
    overflow: visible;
  }

  .panel-controls {
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
  }
}

/* Typography */
h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #333;
}

h3 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: #555;
}

h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* Cards */
.card {
  background: white;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.panel-results .card {
  box-shadow: none;
  border-radius: 0;
  margin-bottom: 0;
}

/* Form sections */
.form-section {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid #eee;
}

.form-section:last-of-type {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.form-group {
  margin-bottom: 0.5rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  color: #444;
}

.form-group input[type="number"] {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid #ddd;
  border-radius: 5px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.form-group input[type="number"]:focus {
  outline: none;
  border-color: #0066cc;
}

.help-text {
  display: block;
  font-size: 0.7rem;
  color: #888;
  margin-top: 0.15rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

@media (max-width: 500px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Buttons */
.button-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 5px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-small {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-primary {
  background: #0066cc;
  color: white;
}

.btn-primary:hover {
  background: #0052a3;
}

.btn-secondary {
  background: #e8e8ed;
  color: #333;
}

.btn-secondary:hover {
  background: #d8d8dd;
}

/* Results header */
.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.results-header h2 {
  margin-bottom: 0;
}

/* Results summary */
.results-summary {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.result-box {
  flex: 1;
  padding: 0.75rem;
  border-radius: 8px;
  text-align: center;
}

.result-box.positive {
  background: #e6f4ea;
  border: 1px solid #34a853;
}

.result-box.negative {
  background: #fce8e6;
  border: 1px solid #ea4335;
}

.result-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: #555;
  margin-bottom: 0.15rem;
}

.result-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.result-box.positive .result-value {
  color: #1e7e34;
}

.result-box.negative .result-value {
  color: #c5221f;
}

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

th,
td {
  padding: 0.4rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

th {
  font-weight: 600;
  font-size: 0.8rem;
  color: #555;
  background: #f9f9fb;
}

td.numeric,
th.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tfoot td {
  border-top: 2px solid #ddd;
  border-bottom: none;
}

/* Summary grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.summary-item {
  padding: 0.5rem;
  background: #f9f9fb;
  border-radius: 5px;
}

.summary-label {
  display: block;
  font-size: 0.7rem;
  color: #666;
  margin-bottom: 0.1rem;
}

.summary-value {
  font-size: 1rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Notes */
.notes {
  margin-top: 1rem;
  padding: 0.75rem;
  background: #fff8e1;
  border-radius: 5px;
  border-left: 3px solid #ffc107;
}

.notes ul {
  list-style: disc;
  padding-left: 1.25rem;
  font-size: 0.8rem;
}

.notes li {
  margin-bottom: 0.15rem;
}

/* Footer */
footer {
  padding: 1rem;
  font-size: 0.75rem;
  color: #888;
  text-align: center;
  border-top: 1px solid #eee;
}

footer p {
  margin-bottom: 0.15rem;
}

/* Decile section */
.decile-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #eee;
}

.decile-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #f9f9fb;
  border-radius: 5px;
}

.positive-text {
  color: #1e7e34;
}

.negative-text {
  color: #c5221f;
}

.decile-note {
  font-size: 0.7rem;
  color: #888;
  margin-top: 0.25rem;
  text-align: center;
}

/* Hidden */
[x-cloak] {
  display: none !important;
}

/* Info buttons */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
  padding: 0;
  margin-left: 0.35rem;
  border: 1px solid #ccc;
  border-radius: 50%;
  background: #f5f5f7;
  color: #666;
  font-size: 0.65rem;
  font-weight: 600;
  font-style: italic;
  font-family: Georgia, serif;
  cursor: pointer;
  transition: all 0.2s;
  vertical-align: middle;
}

.info-btn:hover {
  background: #0066cc;
  border-color: #0066cc;
  color: white;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal {
  background: white;
  border-radius: 10px;
  padding: 1.25rem;
  max-width: 550px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  background: #f5f5f7;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
}

.modal-close:hover {
  background: #e8e8ed;
}

.modal h3 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: #1a1a2e;
  padding-right: 1.5rem;
}

.modal h4 {
  font-size: 0.95rem;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  color: #333;
}

.modal p {
  margin-bottom: 0.6rem;
  color: #444;
  font-size: 0.9rem;
}

.modal ul {
  margin-bottom: 0.6rem;
  padding-left: 1.25rem;
}

.modal li {
  margin-bottom: 0.25rem;
  color: #444;
  font-size: 0.9rem;
}

.modal code {
  background: #f5f5f7;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.85em;
  color: #c5221f;
}

.modal em {
  color: #666;
  font-size: 0.8rem;
}
