/* Global Vars */
:root {
  --primary-blue: #1e5372;
  --primary-orange: #e07a3c;
  --bg-color: #f8fafc;
  --text-main: #333;
  --border-color: #cbd5e1;
  --param-input-width: 140px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.dashboard-header {
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dashboard-header h1 {
  margin: 0;
  font-size: 1.2rem;
  color: #0f172a;
}

.header-controls {
  display: flex;
  gap: 20px;
  align-items: center;
}

.test-selector {
  display: flex;
  align-items: center;
  gap: 10px;
}

.test-selector .label {
  font-weight: bold;
}

.manual-link {
  font-size: 0.9rem;
  color: var(--primary-blue);
  text-decoration: none;
}

.alert-banner {
  margin-left: auto;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 8px;
  padding: 10px 14px;
  max-width: 720px;
}

.alert-banner ul {
  margin: 0;
  padding-left: 20px;
}

.alert-actions {
  margin-top: 10px;
}

/* Main Dashboard Grid */
.dashboard-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  max-width: 1000px;
  margin: 0 auto;
  padding: 30px;
  flex: 1;
}

.dashboard-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Panels & Sections */
h3 {
  margin: 0 0 16px 0;
  font-size: 1.1rem;
  color: #444;
  font-weight: 600;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 8px;
}

.panel {
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  border: 1px solid #f1f5f9;
}

.form-group {
  margin-bottom: 16px;
}

/* Custom File Upload */
.custom-file-upload {
  display: block;
  background: var(--primary-orange);
  color: white;
  text-align: center;
  padding: 10px;
  cursor: pointer;
  font-weight: 600;
  border-radius: 6px;
  transition: opacity 0.2s;
}

.custom-file-upload:hover {
  opacity: 0.9;
}

input[type="file"] {
  display: none;
}

/* Input Styles */
input[type="text"],
input[type="number"] {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: right;
  box-sizing: border-box;
  font-size: 0.95rem;
}

/* Parameter Rows - Themed */
.param-row {
  display: flex;
  align-items: center;
  margin-bottom: 0;
  /* Reset for grid */
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}

.param-row label {
  flex: 1;
  padding: 8px 12px;
  color: white;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.param-row .input-wrapper {
  display: flex;
  align-items: center;
  background: #fff;
  padding-right: 12px;
  flex: none;
  width: var(--param-input-width);
  min-width: var(--param-input-width);
  max-width: var(--param-input-width);
  justify-content: flex-end;
}

.param-row input {
  width: 100%;
  border: none;
  text-align: right;
  font-size: 1rem;
  outline: none;
  font-family: inherit;
}

.param-row .unit {
  margin-left: 6px;
  font-size: 0.8rem;
  color: #64748b;
  white-space: nowrap;
}

/* Theme Colors */
.blue-theme label,
.time-label.blue-theme {
  background-color: #334155;
  /* Slate 700 */
}

.orange-theme label,
.scale-box {
  background-color: #ea580c;
  /* Orange 600 */
}

.custom-file-upload {
  background-color: #ea580c;
}

/* Grid Layout for Tank & Grid Parameters */
[data-shape="rectangle"],
[data-shape="circle"] {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Stack label/input in grid items to prevent truncation */
[data-shape="rectangle"] .param-row,
[data-shape="circle"] .param-row {
  flex-direction: column;
  align-items: stretch;
}

[data-shape="rectangle"] .param-row label,
[data-shape="circle"] .param-row label {
  text-align: center;
  white-space: normal;
  /* Allow wrapping if extremely long */
  overflow: visible;
  padding: 6px 4px;
  font-size: 0.85rem;
}

[data-shape="rectangle"] .param-row .input-wrapper,
[data-shape="circle"] .param-row .input-wrapper {
  flex: none;
  width: 100%;
  min-width: 0;
  max-width: none;
  border-top: 1px solid #e2e8f0;
  justify-content: center;
  padding: 6px;
}

[data-shape="rectangle"] .param-row input,
[data-shape="circle"] .param-row input {
  width: 80%;
  text-align: center;
}

.input-group {
  display: flex;
  align-items: center;
  background: #fff;
  padding: 0 10px;
}

/* Keep Zone Definition row width aligned with other parameter rows */
.zone-definition-inputs {
  justify-content: center !important;
  gap: 6px;
  padding-right: 0;
}

.short-input {
  width: 56px !important;
  text-align: center;
  border: 1px solid var(--border-color) !important;
  margin: 0 4px;
  border-radius: 4px;
  color: #0f172a;
}

.zone-definition-inputs .short-input {
  width: 56px !important;
  margin: 0;
}

/* Scale Calculation Area */
.scale-cal-area {
  margin-top: 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.scale-box {
  color: white;
  padding: 12px;
  width: 100px;
  text-align: center;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  border-radius: 6px;
  font-weight: 500;
}

.scale-inputs {
  flex: 1;
  min-width: 0;
}

.scale-row {
  display: grid;
  grid-template-columns: 80px 16px 80px;
  column-gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  width: max-content;
}

.scale-row input {
  width: 80px;
  border: 1px solid #ea580c;
  color: #ea580c;
  font-weight: 500;
}

.connector {
  margin: 0;
  font-weight: bold;
  color: #cbd5e1;
  text-align: center;
}

.scale-labels {
  display: grid;
  grid-template-columns: 80px 16px 80px;
  column-gap: 8px;
  font-size: 0.75rem;
  color: #64748b;
  width: max-content;
}

.scale-labels span {
  text-align: center;
  white-space: nowrap;
}

.scale-labels span:first-child {
  grid-column: 1;
}

.scale-labels span:last-child {
  grid-column: 3;
  text-align: left;
  justify-self: start;
}

.vis-text.hidden,
.hidden {
  display: none !important;
}

/* Time Settings */
.time-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.time-block {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.time-label {
  color: white;
  padding: 8px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
}

.time-input {
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.time-input input {
  width: 60px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 1rem;
  padding: 4px;
  margin-right: 4px;
}

.time-input span {
  font-size: 0.8rem;
  color: #64748b;
}

.submit-area {
  margin-top: 24px;
  text-align: right;
}

.run-button {
  background: #0f172a;
  /* Darker blue/black for action */
  color: white;
  border: none;
  border-radius: 6px;
  padding: 12px 40px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.run-button:hover {
  background: #1e293b;
}

.submit-area {
  margin-top: 20px;
  text-align: right;
}


.preset-button {
  background: #fff;
  border: 1px solid var(--primary-blue);
  color: var(--primary-blue);
  padding: 5px 15px;
  cursor: pointer;
}

.preset-button:hover,
.preset-button.active {
  /* active class logic needs JS if we want highlight */
  background: #e0f2fe;
}

/* Notes */
.note-center,
.notes-list,
.time-notes {
  font-size: 0.75rem;
  color: #666;
  margin-top: 4px;
}

.note-center {
  text-align: center;
  margin-bottom: 10px;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.time-notes {
  display: flex;
  justify-content: space-around;
  margin-bottom: 10px;
}

/* Output List Section */
.output-list-section {
  padding: 20px;
  background: #fff;
  border-top: 1px solid #ddd;
}

.section-header {
  margin-bottom: 8px;
}

.section-header h2 {
  margin: 0 0 4px;
}

.section-header p {
  margin: 0;
  color: #475569;
}

.list-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.button-primary,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button-primary {
  border: 1px solid #0f172a;
  background: #0f172a;
  color: #fff;
}

.secondary-button {
  border: 1px solid #94a3b8;
  background: #fff;
  color: #0f172a;
}

.download-link {
  color: #1d4ed8;
}

.table-container {
  overflow-x: auto;
  margin-top: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 8px;
  border: 1px solid #eee;
  text-align: left;
}

th {
  background: #f1f5f9;
}

.output-history-table {
  table-layout: fixed;
}

.output-history-table th,
.output-history-table td {
  width: calc(100% / 13);
  max-width: calc(100% / 13);
}

.output-history-table th {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.output-history-table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

/* Responsive */
@media (max-width: 1200px) {
  .dashboard-container {
    grid-template-columns: 1fr;
  }

  .blue-box {
    height: 300px;
  }
}
