/* =================================
   GLOBAL RESET & BASE STYLES
   ================================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: Cambria, Georgia, 'Times New Roman', serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #e8eef5 100%);
  color: #2c3e50;
  font-size: 14px;
  line-height: 1.6;
  padding: 20px 10px;
  min-height: 100vh;
}

/* =================================
   CONTAINER
   ================================= */
.container {
  max-width: 1400px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
  overflow: hidden;
}

/* =================================
   HEADER
   ================================= */
.header {
  background: linear-gradient(135deg, #003366 0%, #004d99 100%);
  color: #fff;
  padding: 25px 35px;
  border-bottom: 4px solid #002244;
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.credit {
  font-style: italic;
  font-size: 13px;
  opacity: 0.9;
  margin: 4px 0;
}

.credit a {
  color: #fff;
  text-decoration: none;
  border-bottom: 1px dotted rgba(255,255,255,0.6);
  transition: all 0.3s;
}

.credit a:hover {
  border-bottom-color: #fff;
  opacity: 1;
}

.github-link {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  margin-top: 6px;
}

.github-link i {
  font-size: 16px;
}

/* =================================
   SECTIONS
   ================================= */
.section {
  padding: 30px 35px;
  border-bottom: 1px solid #e9ecef;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: #003366;
  margin-bottom: 25px;
  padding-bottom: 12px;
  border-bottom: 3px solid #003366;
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 20px;
  font-weight: 700;
  color: #003366;
  margin-bottom: 25px;
  padding-bottom: 12px;
  border-bottom: 3px solid #003366;
}

.section-title-flex > div {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* =================================
   DEMO BUTTONS
   ================================= */
.demo-buttons {
  display: flex;
  gap: 12px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.btn-demo {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: #003366;
  border: 2px solid #dee2e6;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.btn-demo:hover {
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
  border-color: #003366;
  transform: translateY(-2px);
}

/* =================================
   PARAMETER & CONTROL CARDS
   ================================= */
.param-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 25px;
  margin-bottom: 25px;
}

.param-card {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  border: 2px solid #e9ecef;
  border-radius: 10px;
  padding: 20px;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.param-card:hover {
  border-color: #003366;
  box-shadow: 0 4px 16px rgba(0,51,102,0.1);
  transform: translateY(-2px);
}

.param-header {
  font-weight: 700;
  color: #003366;
  margin-bottom: 18px;
  font-size: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e9ecef;
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.control-card {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  padding: 20px;
  transition: all 0.3s;
}

.control-card:hover {
  border-color: #003366;
  box-shadow: 0 4px 12px rgba(0,51,102,0.1);
}

.control-header {
  font-weight: 700;
  color: #003366;
  margin-bottom: 15px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 2px solid #dee2e6;
}

.control-note {
  font-size: 13px;
  color: #6c757d;
  font-style: italic;
  padding: 10px;
  background: #ffffff;
  border-radius: 6px;
  border-left: 3px solid #6c757d;
}

/* =================================
   GRIDS
   ================================= */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  align-items: end;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 15px;
  align-items: end;
}

/* =================================
   INPUT GROUPS
   ================================= */
.input-group {
  display: flex;
  flex-direction: column;
}

.input-group label {
  font-weight: 600;
  margin-bottom: 6px;
  color: #495057;
  font-size: 13px;
  line-height: 18px;
  min-height: 24px;
  display: flex;
  align-items: center;
}

.input-group input,
.input-group select {
  padding: 10px 14px;
  border: 2px solid #dee2e6;
  border-radius: 6px;
  font-family: Cambria, Georgia, serif;
  font-size: 14px;
  transition: all 0.3s;
  background: #fff;
  height: 42px;
  line-height: 20px;
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: #003366;
  box-shadow: 0 0 0 4px rgba(0,51,102,0.1);
}

.input-group input::placeholder {
  color: #adb5bd;
  font-style: italic;
}

/* =================================
   CALCULATED RESULT BOX
   ================================= */
.calc-result {
  background: linear-gradient(135deg, #fff9e6 0%, #fffaed 100%);
  border: 2px solid #ffd54f;
  border-radius: 10px;
  padding: 20px;
  margin-top: 25px;
  display: none;
  box-shadow: 0 2px 8px rgba(255,193,7,0.1);
}

.calc-result.show {
  display: block;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.calc-result-header {
  font-weight: 700;
  color: #f57c00;
  margin-bottom: 15px;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.calc-result-content {
  font-size: 14px;
  line-height: 2;
  color: #5d4037;
}

.calc-highlight {
  color: #c41e3a;
  font-weight: 700;
  background: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  display: inline-block;
}

/* =================================
   OVERRIDE SECTION
   ================================= */
.override-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px dashed #dee2e6;
}

.override-header {
  font-weight: 600;
  color: #6c757d;
  margin-bottom: 12px;
  font-size: 14px;
}

.override-note {
  margin-top: 10px;
  font-size: 12px;
  color: #6c757d;
  font-style: italic;
}

/* =================================
   FORMULA BOX
   ================================= */
.formula-box {
  background: linear-gradient(135deg, #e3f2fd 0%, #f5f9ff 100%);
  border: 2px solid #90caf9;
  border-radius: 10px;
  padding: 25px;
  margin-top: 25px;
  box-shadow: 0 2px 8px rgba(33,150,243,0.1);
}

.formula-header {
  font-weight: 700;
  color: #1565c0;
  margin-bottom: 20px;
  font-size: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.formula-item {
  background: #fff;
  border-left: 4px solid #1976d2;
  padding: 16px;
  border-radius: 6px;
  display: flex;
  gap: 15px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  transition: all 0.3s;
  min-height: 70px;
  align-items: center;
}

.formula-item:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  transform: translateX(3px);
}

.formula-number {
  background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(25,118,210,0.3);
}

.formula-content {
  flex: 1;
}

.formula-title {
  font-weight: 600;
  color: #37474f;
  margin-bottom: 6px;
  font-size: 14px;
}

.formula-expr {
  font-family: 'Cambria Math', Cambria, serif;
  font-size: 15px;
  font-style: italic;
  color: #546e7a;
}

.formula-note {
  background: #fff3cd;
  border: 2px solid #ffc107;
  border-radius: 6px;
  padding: 12px;
  font-size: 13px;
  color: #856404;
  font-weight: 600;
}

/* =================================
   TABLES
   ================================= */
.table-container {
  overflow-x: auto;
  border-radius: 10px;
  border: 2px solid #e9ecef;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  padding: 12px 10px;
  text-align: center;
  border-bottom: 1px solid #e9ecef;
  height: 52px;
  vertical-align: middle;
}

th {
  background: linear-gradient(135deg, #003366 0%, #004d99 100%);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}

tbody tr {
  transition: background 0.2s;
}

tbody tr:hover {
  background: #f8f9fa;
}

td input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid #dee2e6;
  border-radius: 6px;
  font-family: Cambria, Georgia, serif;
  font-size: 14px;
  text-align: center;
  transition: all 0.3s;
  height: 38px;
  line-height: 20px;
}

td input[type="number"]:focus {
  outline: none;
  border-color: #003366;
  background: #fffaed;
  box-shadow: 0 0 0 3px rgba(0,51,102,0.1);
}

td input[type="checkbox"],
th input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #003366;
}

/* Calculated cells in table */
.calc-cell {
  background: linear-gradient(135deg, #e3f2fd 0%, #f5f9ff 100%);
  font-weight: 700;
  color: #1976d2;
  font-size: 15px;
}

.calc-cell:empty {
  background: #fff;
}

/* =================================
   BUTTONS
   ================================= */
.btn {
  background: #003366;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 20px;
  font-family: Cambria, Georgia, serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.3s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  height: 42px;
  line-height: 20px;
  white-space: nowrap;
}

.btn:hover {
  background: #002244;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn:active {
  transform: translateY(0);
}

.btn i {
  font-size: 14px;
}

.btn-primary {
  background: linear-gradient(135deg, #003366 0%, #004d99 100%);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #002244 0%, #003366 100%);
}

.btn-red {
  background: linear-gradient(135deg, #c41e3a 0%, #a01828 100%);
}

.btn-red:hover {
  background: linear-gradient(135deg, #a01828 0%, #801020 100%);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 13px;
  height: 36px;
  line-height: 18px;
}

.btn-large {
  padding: 12px 28px;
  font-size: 15px;
  font-weight: 700;
  height: 48px;
  line-height: 22px;
}

.btn-icon {
  background: transparent;
  color: #c41e3a;
  border: none;
  padding: 8px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.3s;
  box-shadow: none;
  height: 36px;
  width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: #c41e3a;
  color: #fff;
  transform: scale(1.1);
}

.btn-collapse {
  background: #f8f9fa;
  color: #003366;
  border: 2px solid #dee2e6;
  padding: 8px 16px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: none;
  font-weight: 600;
  height: 38px;
  line-height: 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-collapse:hover {
  background: #e9ecef;
  border-color: #003366;
  transform: none;
}

.action-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 20px;
  align-items: center;
}

/* =================================
   CHECKBOX GROUPS
   ================================= */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px;
  border-radius: 6px;
  transition: background 0.2s;
  font-weight: 500;
  height: 42px;
  line-height: 20px;
}

.checkbox-label:hover {
  background: rgba(0,51,102,0.05);
}

.checkbox-label input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #003366;
  flex-shrink: 0;
}

.checkbox-label span {
  font-size: 14px;
  color: #495057;
}

/* =================================
   ITEM LISTS
   ================================= */
.item-list {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.item-list-item {
  background: #fff;
  border: 2px solid #dee2e6;
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  transition: all 0.3s;
  min-height: 60px;
}

.item-list-item:hover {
  border-color: #003366;
  box-shadow: 0 2px 8px rgba(0,51,102,0.1);
}

/* =================================
   GRAPH SECTION
   ================================= */
.graph-section {
  background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
  padding: 30px 35px;
}

.graph-container {
  background: #fff;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  padding: 25px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.graph-container.collapsed {
  display: none;
}

.graph-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 15px;
}

.info-badge {
  background: linear-gradient(135deg, #e3f2fd 0%, #f5f9ff 100%);
  border: 2px solid #90caf9;
  color: #1565c0;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  height: 42px;
  line-height: 18px;
}

#plotlyGraph {
  border: 3px solid #003366;
  border-radius: 8px;
  background: #fefef8;
  overflow-x: auto;
}

/* =================================
   REPORT FORM
   ================================= */
.report-form {
  background: #f8f9fa;
  border: 2px solid #e9ecef;
  border-radius: 10px;
  padding: 25px;
}

/* =================================
   LOADING OVERLAY
   ================================= */
.loading {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.7);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.loading.show {
  display: flex;
}

.loading > div:last-child {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  margin-top: 20px;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 6px solid rgba(255,255,255,0.3);
  border-top: 6px solid #fff;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* =================================
   RESPONSIVE - TABLET
   ================================= */
@media (max-width: 1024px) {
  .param-grid,
  .control-grid {
    grid-template-columns: 1fr;
  }
  
  .formula-grid {
    grid-template-columns: 1fr;
  }
}

/* =================================
   RESPONSIVE - MOBILE (768px and below)
   ================================= */
@media (max-width: 768px) {
  /* Body & Container */
  body {
    padding: 5px;
  }
  
  .container {
    border-radius: 8px;
  }
  
  /* Header */
  .header {
    padding: 15px 18px;
  }
  
  .header h1 {
    font-size: 20px;
    gap: 8px;
  }
  
  .credit {
    font-size: 11px;
    margin: 3px 0;
  }
  
  .github-link {
    font-size: 10px;
    gap: 6px;
    margin-top: 4px;
  }
  
  .github-link i {
    font-size: 13px;
  }
  
  /* Sections */
  .section {
    padding: 18px 15px;
  }
  
  .section-title,
  .section-title-flex {
    font-size: 16px;
    margin-bottom: 15px;
    padding-bottom: 8px;
    gap: 8px;
  }
  
  /* Cards */
  .param-card,
  .control-card {
    padding: 12px;
    border-radius: 8px;
  }
  
  .param-header,
  .control-header {
    font-size: 14px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    gap: 6px;
  }
  
  .param-grid,
  .control-grid {
    gap: 12px;
    margin-bottom: 15px;
  }
  
  /* Grids */
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  /* Input Groups */
  .input-group {
    margin-bottom: 0;
  }
  
  .input-group label {
    font-size: 12px;
    margin-bottom: 4px;
    min-height: 18px;
  }
  
  .input-group input,
  .input-group select {
    padding: 8px 10px;
    font-size: 13px;
    height: 38px;
  }
  
  /* Buttons */
  .btn {
    padding: 8px 16px;
    font-size: 13px;
    height: 38px;
    gap: 6px;
  }
  
  .btn i {
    font-size: 12px;
  }
  
  .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    height: 32px;
  }
  
  .btn-large {
    padding: 10px 20px;
    font-size: 14px;
    height: 42px;
  }
  
  .demo-buttons,
  .action-buttons {
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
  }
  
  .btn {
    width: 100%;
    justify-content: center;
  }
  
  /* Calculated Results */
  .calc-result {
    padding: 12px;
    margin-top: 15px;
  }
  
  .calc-result-header {
    font-size: 14px;
    margin-bottom: 10px;
    gap: 6px;
  }
  
  .calc-result-content {
    font-size: 12px;
    line-height: 1.6;
  }
  
  .calc-highlight {
    padding: 1px 6px;
    font-size: 12px;
  }
  
  .override-section {
    margin-top: 12px;
    padding-top: 12px;
  }
  
  .override-header {
    font-size: 12px;
    margin-bottom: 8px;
  }
  
  .override-note {
    font-size: 11px;
    margin-top: 6px;
  }
  
  /* Formula Box */
  .formula-box {
    padding: 15px;
    margin-top: 15px;
  }
  
  .formula-header {
    font-size: 15px;
    margin-bottom: 12px;
    gap: 6px;
  }
  
  .formula-grid {
    gap: 10px;
    margin-bottom: 12px;
  }
  
  .formula-item {
    padding: 10px;
    gap: 10px;
    min-height: 60px;
  }
  
  .formula-number {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }
  
  .formula-title {
    font-size: 12px;
    margin-bottom: 4px;
  }
  
  .formula-expr {
    font-size: 13px;
  }
  
  .formula-note {
    padding: 8px;
    font-size: 11px;
  }
  
  /* Tables */
  table {
    font-size: 11px;
  }
  
  th, td {
    padding: 8px 4px;
    height: 42px;
  }
  
  td input[type="number"] {
    padding: 6px 8px;
    font-size: 12px;
    height: 32px;
  }
  
  td input[type="checkbox"],
  th input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }
  
  .calc-cell {
    font-size: 13px;
  }
  
  /* Checkbox Groups */
  .checkbox-group {
    gap: 8px;
  }
  
  .checkbox-label {
    padding: 8px;
    height: 36px;
    gap: 8px;
  }
  
  .checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }
  
  .checkbox-label span {
    font-size: 12px;
  }
  
  /* Item Lists */
  .item-list {
    margin-top: 10px;
    gap: 8px;
  }
  
  .item-list-item {
    padding: 10px 12px;
    font-size: 11px;
    min-height: 50px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  /* Graph Section */
  .graph-section {
    padding: 18px 15px;
  }
  
  .graph-container {
    padding: 12px;
  }
  
  .graph-info {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
  }
  
  .info-badge {
    padding: 8px 12px;
    font-size: 11px;
    height: 36px;
    width: 100%;
    justify-content: center;
  }
  
  #plotlyGraph {
    border-width: 2px;
  }
  
  /* Report Form */
  .report-form {
    padding: 15px;
  }
  
  /* Control Notes */
  .control-note {
    font-size: 11px;
    padding: 8px;
  }
  
  /* Loading */
  .loading > div:last-child {
    font-size: 15px;
    margin-top: 15px;
  }
  
  .spinner {
    width: 50px;
    height: 50px;
    border-width: 5px;
  }
}

/* =================================
   RESPONSIVE - SMALL MOBILE (480px and below)
   ================================= */
@media (max-width: 480px) {
  /* Further reduce for very small screens */
  body {
    padding: 3px;
  }
  
  .header {
    padding: 12px 15px;
  }
  
  .header h1 {
    font-size: 18px;
    gap: 6px;
  }
  
  .credit {
    font-size: 10px;
  }
  
  .github-link {
    font-size: 9px;
    gap: 5px;
  }
  
  .github-link i {
    font-size: 12px;
  }
  
  .section {
    padding: 15px 12px;
  }
  
  .section-title,
  .section-title-flex {
    font-size: 14px;
    margin-bottom: 12px;
    padding-bottom: 6px;
  }
  
  .param-card,
  .control-card {
    padding: 10px;
  }
  
  .param-header,
  .control-header {
    font-size: 13px;
    margin-bottom: 8px;
    padding-bottom: 5px;
  }
  
  .input-group label {
    font-size: 11px;
  }
  
  .input-group input,
  .input-group select {
    font-size: 12px;
    height: 36px;
  }
  
  .btn {
    font-size: 12px;
    height: 36px;
    padding: 7px 14px;
  }
  
  .btn-large {
    font-size: 13px;
    height: 40px;
  }
  
  .formula-expr {
    font-size: 12px;
  }
  
  table {
    font-size: 10px;
  }
  
  th, td {
    padding: 6px 3px;
    height: 38px;
  }
  
  td input[type="number"] {
    font-size: 11px;
    height: 30px;
    padding: 5px 6px;
  }
  
  .calc-cell {
    font-size: 12px;
  }
  
  .calc-result-content {
    font-size: 11px;
  }
  
  .info-badge {
    font-size: 10px;
    height: 34px;
    padding: 6px 10px;
  }
}

