/* WAIFU MILK PRODUCTION — Physiological Lactation Simulation Dashboard */
/* Flat, High-Contrast Dark Navy & Charcoal Theme */

:root {
  --bg-app: #0b0d14;
  --bg-header: #121520;
  --bg-card: #131622;
  --bg-card-hover: #161a29;
  --bg-card-inner: #181c2b;
  --bg-input: #0d0f17;
  --bg-input-focus: #111420;
  --bg-track: #1b2030;
  
  --border-card: #232a3d;
  --border-card-subtle: #1c2233;
  --border-input: #262e42;
  --border-input-focus: #3b82f6;
  --border-header: #1b2030;
  
  --text-white: #ffffff;
  --text-title: #f0f2f7;
  --text-primary: #cfd4e2;
  --text-secondary: #8c96ac;
  --text-muted: #5d6882;
  
  --accent-blue: #3b82f6;
  --accent-blue-hover: #2563eb;
  --accent-cyan: #38bdf8;
  
  --badge-hybrid-border: #9333ea;
  --badge-hybrid-bg: #271438;
  --badge-hybrid-text: #e879f9;
  
  --badge-research-border: #0ea5e9;
  --badge-research-bg: #102538;
  --badge-research-text: #7dd3fc;
  
  --badge-formula-border: #1e3a8a;
  --badge-formula-bg: #111d33;
  --badge-formula-text: #60a5fa;
  
  --badge-ceiling-border: #831843;
  --badge-ceiling-bg: #2d121e;
  --badge-ceiling-text: #f472b6;
  
  --radius-card: 10px;
  --radius-sm: 6px;
  
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --transition-fast: 0.16s ease;
}

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

html, body {
  min-height: 100vh;
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-stack);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* APP WRAPPER */
.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* TOP HEADER */
.app-header {
  height: 54px;
  background-color: var(--bg-header);
  border-bottom: 1px solid var(--border-header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
}

.brand-icon {
  width: 18px;
  height: 18px;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-title);
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-header {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background-color: #171b27;
  border: 1px solid #283044;
  color: #cfd4e2;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-header:hover {
  background-color: #202636;
  border-color: #3b4664;
  color: #ffffff;
}

.btn-header svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
}

/* MAIN CONTENT */
.main-content {
  flex: 1;
  padding: 18px 24px;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* 3-COLUMN DASHBOARD GRID */
.dashboard-grid {
  display: grid;
  grid-template-columns: 370px minmax(440px, 1.4fr) minmax(320px, 1fr);
  grid-template-rows: auto auto auto;
  gap: 16px;
  align-items: stretch;
}

/* UNIVERSAL CARD STYLES (FLAT HIGH-CONTRAST) */
.dashboard-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  position: relative;
  display: flex;
  flex-direction: column;
}

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

.card-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* BADGES (FLAT) */
.badge-mode {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--badge-hybrid-border);
  background: var(--badge-hybrid-bg);
  color: var(--badge-hybrid-text);
  transition: all var(--transition-fast);
}

.badge-mode:hover {
  filter: brightness(1.15);
}

.badge-mode.mode-research {
  border-color: var(--badge-research-border);
  background: var(--badge-research-bg);
  color: var(--badge-research-text);
}

.badge-subtle {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 3px;
  text-transform: uppercase;
}

.badge-formula {
  background-color: var(--badge-formula-bg);
  border: 1px solid var(--badge-formula-border);
  color: var(--badge-formula-text);
}

.badge-ceiling {
  background-color: var(--badge-ceiling-bg);
  border: 1px solid var(--badge-ceiling-border);
  color: var(--badge-ceiling-text);
}

/* COLUMN 1: CHARACTER INPUT CARD (SCROLLABLE SIDEBAR) */
.card-character {
  grid-column: 1;
  grid-row: 1 / span 3;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  padding-right: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

/* Custom scrollbar for sidebar */
.card-character::-webkit-scrollbar {
  width: 6px;
}
.card-character::-webkit-scrollbar-track {
  background: #0d0f17;
  border-radius: 3px;
}
.card-character::-webkit-scrollbar-thumb {
  background: #252d42;
  border-radius: 3px;
}
.card-character::-webkit-scrollbar-thumb:hover {
  background: #3b82f6;
}

.character-profile-header {
  border-bottom: 1px solid #1c2233;
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.character-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.character-name-input {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-white);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  width: 200px;
  padding: 2px 4px;
  border-radius: 4px;
  outline: none;
  transition: border-color var(--transition-fast);
}

.character-name-input:hover {
  border-color: #2b334a;
}

.character-name-input:focus {
  border-color: var(--accent-blue);
  background-color: #0e111a;
}

.character-id-meta {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* INPUT SECTIONS */
.input-sections-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-section-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid #1a2030;
  padding-bottom: 12px;
}

.form-section-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #9aa5bf;
  text-transform: uppercase;
  margin-bottom: 2px;
}

.form-group-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.field-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.field-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border-input);
  color: var(--text-title);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: all var(--transition-fast);
}

.field-control:focus {
  border-color: var(--border-input-focus);
  background-color: var(--bg-input-focus);
}

select.field-control {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238c96ac' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 11px;
  padding-right: 26px;
  cursor: pointer;
}

select.field-control option {
  background-color: #121520;
  color: var(--text-title);
}

.input-stepper {
  width: 95px;
  text-align: left;
}

.select-standard {
  flex: 1;
  max-width: 210px;
}

/* SLIDERS */
.slider-group-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.slider-group-row .field-label {
  width: 120px;
  flex-shrink: 0;
}

.slider-track-wrap {
  flex: 1;
  display: flex;
  align-items: center;
}

.custom-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-track);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.custom-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  border: 2px solid #ffffff;
}

.custom-slider::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  border: 2px solid #ffffff;
}

.slider-val-badge {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-title);
  width: 44px;
  text-align: right;
  flex-shrink: 0;
}

/* CARD BOTTOM ACTIONS */
.card-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #1a2030;
}

.btn-primary {
  flex: 1.2;
  background-color: var(--accent-blue);
  color: #ffffff;
  border: 1px solid #2563eb;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  background-color: var(--accent-blue-hover);
}

.btn-secondary {
  flex: 1;
  background-color: #171a26;
  color: var(--text-primary);
  border: 1px solid #283044;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background-color: #212638;
  border-color: #3b4664;
  color: #ffffff;
}

.btn-primary svg, .btn-secondary svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
}

/* STAT CARDS (OUTPUT & CEILING) */
.card-output {
  grid-column: 2;
  grid-row: 1;
}

.card-ceiling {
  grid-column: 3;
  grid-row: 1;
}

.stat-value-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0 8px 0;
}

.stat-number-huge {
  font-size: 38px;
  font-weight: 700;
  color: var(--text-white);
  line-height: 1;
  letter-spacing: -0.5px;
}

.stat-unit-label {
  font-size: 17px;
  font-weight: 400;
  color: var(--text-secondary);
}

.stat-annotation {
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.annotation-highlight {
  color: #a3b0cc;
}

/* TIMELINE CHART CARD */
.card-timeline {
  grid-column: 2;
  grid-row: 2;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11.5px;
  color: var(--text-secondary);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-indicator-solid {
  display: inline-block;
  width: 16px;
  height: 2.5px;
  background-color: #3b82f6;
  border-radius: 2px;
}

.legend-indicator-dashed {
  display: inline-block;
  width: 16px;
  height: 2px;
  border-bottom: 2px dashed #4b638f;
}

.chart-svg-container {
  width: 100%;
  height: 160px;
  position: relative;
  margin-top: 4px;
}

.chart-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* CONDITION SCORE CARD */
.card-condition-gauge {
  grid-column: 3;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.gauge-wrapper {
  position: relative;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 4px auto;
}

.gauge-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  transform-origin: center;
}

.gauge-track {
  fill: none;
  stroke: #1e2538;
  stroke-width: 8;
}

.gauge-fill {
  fill: none;
  stroke: #3b82f6;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}

.gauge-score-value {
  position: absolute;
  font-size: 32px;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: -0.5px;
}

.gauge-descriptor-label {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
}

/* MILK COMPOSITION CARD */
.card-composition {
  grid-column: 2;
  grid-row: 3;
}

.comp-bars-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 6px 0 12px 0;
}

.comp-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.comp-component-name {
  width: 105px;
  font-size: 12px;
  color: var(--text-primary);
  flex-shrink: 0;
}

.comp-track-outer {
  flex: 1;
  height: 8px;
  background-color: #1b2030;
  border-radius: 4px;
  overflow: hidden;
}

.comp-bar-fill {
  height: 100%;
  background-color: #3b82f6;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.comp-value-label {
  width: 44px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-title);
  text-align: right;
  flex-shrink: 0;
}

.comp-footer-annotation {
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid #1a2030;
  padding-top: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* WHY THIS RESULT? CARD */
.card-breakdown {
  grid-column: 3;
  grid-row: 3;
}

.numbered-breakdown-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.breakdown-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.step-number-circle {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #2563eb;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-text-content {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.45;
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 16, 0.85);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background-color: #141724;
  border: 1px solid #283149;
  border-radius: 10px;
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

.modal-header {
  padding: 14px 18px;
  border-bottom: 1px solid #20273a;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: #8c96ac;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}

.btn-close-modal:hover {
  color: #ffffff;
}

.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid #20273a;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* PROFILE LIST ITEM */
.profile-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background-color: #1a1e2e;
  border: 1px solid #283046;
  border-radius: 6px;
}

.profile-info-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-info-name {
  font-weight: 600;
  color: #ffffff;
}

.profile-info-meta {
  font-size: 11px;
  color: #8c96ac;
}

.profile-actions-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-sm-action {
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #333d58;
  background: #202638;
  color: #cfd4e2;
}

.btn-sm-action:hover {
  background: #2b334a;
  color: #ffffff;
}

.btn-sm-action.danger:hover {
  background: #7f1d1d;
  border-color: #991b1b;
  color: #fecaca;
}

/* TOAST NOTIFICATION */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background-color: #192033;
  border: 1px solid #2d3b5e;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* TEST RUNNER TABLE */
.test-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.test-table th, .test-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #232b3f;
  text-align: left;
}

.test-table th {
  color: #8c96ac;
  font-weight: 600;
}

.test-pass {
  color: #34d399;
  font-weight: 700;
}

.test-fail {
  color: #f87171;
  font-weight: 700;
}

/* FOOTER */
.app-footer {
  border-top: 1px solid var(--border-header);
  background-color: var(--bg-header);
  padding: 12px 24px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.footer-content {
  max-width: 1600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-link-btn {
  background: transparent;
  border: none;
  color: #7d879e;
  font-size: 11.5px;
  cursor: pointer;
  padding: 0;
  transition: color var(--transition-fast);
}

.footer-link-btn:hover {
  color: var(--accent-cyan);
  text-decoration: underline;
}

/* RESPONSIVE BREAKPOINTS */
@media (max-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: 340px 1.2fr 300px;
    gap: 14px;
  }
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto;
  }
  
  .card-character {
    grid-column: 1 / span 2;
    grid-row: auto;
    max-height: none;
  }
  
  .card-output {
    grid-column: 1;
    grid-row: auto;
  }
  
  .card-ceiling {
    grid-column: 2;
    grid-row: auto;
  }
  
  .card-timeline {
    grid-column: 1 / span 2;
    grid-row: auto;
  }
  
  .card-condition-gauge {
    grid-column: 1;
    grid-row: auto;
  }
  
  .card-composition {
    grid-column: 2;
    grid-row: auto;
  }
  
  .card-breakdown {
    grid-column: 1 / span 2;
    grid-row: auto;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 16px;
  }
  
  .main-content {
    padding: 14px 12px;
  }
  
  .dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
  }
  
  .card-character,
  .card-output,
  .card-ceiling,
  .card-timeline,
  .card-condition-gauge,
  .card-composition,
  .card-breakdown {
    grid-column: auto;
    grid-row: auto;
    width: 100%;
    max-height: none;
  }
  
  .character-name-input {
    width: 160px;
    font-size: 16px;
  }
  
  .stat-number-huge {
    font-size: 32px;
  }
  
  .card-actions-row {
    flex-wrap: wrap;
  }
  
  .btn-primary, .btn-secondary {
    flex: 1 1 45%;
  }
}
