/* ===== Base Reset & Typography ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  line-height: 1.5;
}

/* ===== App Layout ===== */
#app {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  max-width: 1600px;
  margin: 0 auto;
  background: #1a1a2e;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.4);
}

#sidebar {
  flex: 3;
  padding: 20px 24px;
  overflow-y: auto;
  border-right: 1px solid #2a2a40;
}

#graph-area {
  flex: 2;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  align-items: stretch;
  background: #16162a;
  border-left: 1px solid #2a2a40;
}

#graph-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== Title ===== */
.app-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: #f0f0f0;
}

/* ===== Tab Bar ===== */
#tab-bar {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 4px;
  border-bottom: 2px solid #2a2a40;
}

.tab-btn {
  padding: 8px 14px;
  border: none;
  background: transparent;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: 6px 6px 0 0;
  color: #888;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.tab-btn:hover {
  background: rgba(33, 150, 243, 0.15);
  color: #ccc;
}

.tab-btn.active {
  background: #2196F3;
  color: #fff;
  font-weight: 600;
}

/* ===== Tab Panels ===== */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ===== Form Controls ===== */
.form-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.form-row label {
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 120px;
  color: #bbb;
}

.form-row input[type="number"] {
  width: 90px;
  padding: 6px 10px;
  border: 1px solid #3a3a50;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: #22223a;
  color: #e0e0e0;
  transition: border-color 0.15s;
}

.form-row input[type="number"]:focus {
  border-color: #2196F3;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.25);
}

.form-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2196F3;
}

.radio-group {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.radio-group label {
  min-width: auto;
  font-weight: 400;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  color: #bbb;
}

.radio-group input[type="radio"] {
  accent-color: #2196F3;
}

/* ===== Buttons ===== */
.btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  background: #2196F3;
  color: #fff;
  font-size: 0.9rem;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.btn:hover {
  background: #1976D2;
}

.btn:active {
  transform: scale(0.97);
}

.btn-row {
  margin: 14px 0;
}

/* ===== Section Headings ===== */
.section-heading {
  font-size: 1rem;
  font-weight: 600;
  margin: 20px 0 8px;
  color: #ddd;
  border-bottom: 1px solid #2a2a40;
  padding-bottom: 4px;
}

.matrix-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #999;
  margin: 14px 0 6px;
}

/* ===== Matrix Tables ===== */
.matrix-wrapper {
  overflow-x: auto;
  margin-bottom: 12px;
  border: 1px solid #2a2a40;
  border-radius: 6px;
}

.matrix-table {
  border-collapse: collapse;
  font-size: 0.78rem;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  width: auto;
  min-width: 100%;
}

.matrix-table th,
.matrix-table td {
  border: 1px solid #2a2a40;
  padding: 4px 7px;
  text-align: center;
  white-space: nowrap;
}

.matrix-table th {
  background: #22223a;
  font-weight: 600;
  color: #aaa;
  position: sticky;
  top: 0;
}

.matrix-table td {
  background: #1e1e32;
  color: #ccc;
}

.matrix-table tr:nth-child(even) td {
  background: #1a1a2e;
}

.matrix-table tr:hover td {
  background: #252545;
}

.cell-highlight-green {
  background: #2e6b2e !important;
  color: #90EE90 !important;
}

.cell-highlight-red {
  background: #6b2e2e !important;
  color: #FFC8C8 !important;
}

.cell-highlight-orange {
  background: #6b4e1e !important;
  color: #FFD4A0 !important;
}

.cell-highlight-blue {
  background: #2e3e6b !important;
  color: #C8DCFF !important;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.8rem;
}

.form-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: #bbb;
}

/* ===== Text Output ===== */
.text-output {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 0.85rem;
  background: #22223a;
  border: 1px solid #2a2a40;
  border-radius: 6px;
  padding: 12px 14px;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 40px;
  line-height: 1.6;
  color: #d0d0d0;
}

/* ===== Weight Type Label ===== */
.info-label {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 10px;
  font-style: italic;
}

/* ===== Mobile Layout ===== */
@media (max-width: 768px) {
  #app {
    flex-direction: column;
  }

  #sidebar {
    border-right: none;
    border-bottom: 1px solid #2a2a40;
    padding: 16px;
  }

  #graph-area {
    position: relative;
    height: 350px;
    flex: none;
    border-left: none;
    border-top: 1px solid #2a2a40;
  }

  .app-title {
    font-size: 1.2rem;
  }

  .tab-btn {
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  .form-row label {
    min-width: 100px;
    font-size: 0.85rem;
  }

  .form-row input[type="number"] {
    width: 75px;
  }
}
