body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: radial-gradient(circle at 20% 20%, rgba(21, 196, 126, 0.12), transparent 35%), #0b1014;
  color: #f5f7fa;
}

#app {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
  justify-content: center;
  padding: 4vh 4vw;
  box-sizing: border-box;
}

.auth {
  background: rgba(13, 19, 24, 0.92);
  backdrop-filter: blur(14px);
  padding: clamp(1.75rem, 3vw, 2.5rem);
  border-radius: 18px;
  width: min(420px, 100%);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.auth h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  letter-spacing: 0.02em;
}

.tabs {
  display: inline-flex;
  background: rgba(20, 27, 34, 0.9);
  border-radius: 12px;
  padding: 0.25rem;
  width: 100%;
  margin-bottom: 1.5rem;
  gap: 0.25rem;
}

.tabs button {
  flex: 1;
  padding: 0.8rem 1rem;
  background: transparent;
  border: none;
  color: #7b8695;
  cursor: pointer;
  font-size: 1rem;
  border-radius: 10px;
  transition: 0.2s ease;
}

.tabs button.active {
  color: #0b1116;
  background: #15c47e;
  font-weight: 600;
}

.form {
  display: none;
  flex-direction: column;
  gap: 0.9rem;
}

.form.active {
  display: flex;
}

input,
textarea,
select,
button {
  width: 100%;
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(12, 17, 21, 0.9);
  color: #f5f7fa;
  font-size: 0.95rem;
  box-sizing: border-box;
}

textarea {
  resize: vertical;
}

button {
  background: linear-gradient(135deg, #15c47e, #20dd91);
  border: none;
  color: #061217;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(21, 196, 126, 0.35);
}

.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #f5f7fa;
}

.secondary:hover {
  box-shadow: none;
  transform: none;
  background: rgba(255, 255, 255, 0.12);
}

.danger {
  background: rgba(248, 113, 113, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.35);
}

.error {
  color: #f87171;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.success {
  color: #34d399;
  font-size: 0.85rem;
  min-height: 1.2em;
}

.hidden {
  display: none !important;
}

.dashboard {
  display: flex;
  width: min(1200px, 100%);
  min-height: 80vh;
  background: rgba(11, 17, 22, 0.94);
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.dashboard aside {
  width: min(360px, 32vw);
  background: linear-gradient(160deg, rgba(15, 23, 32, 0.96), rgba(15, 23, 32, 0.92));
  padding: 2rem 1.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.aside-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

.aside-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: #8c96a5;
}

.card {
  background: rgba(9, 14, 18, 0.92);
  border-radius: 18px;
  padding: 1.25rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.card-header h2,
.card-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

label span {
  display: block;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: #93a0b2;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

label input,
label textarea,
label select {
  margin-top: 0.35rem;
}

.sidebar-actions {
  display: flex;
  gap: 0.75rem;
}

.outcome-history {
  gap: 0.75rem;
}

.outcome-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 260px;
  overflow-y: auto;
}

.outcome-item {
  background: rgba(18, 27, 35, 0.8);
  border-radius: 12px;
  padding: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.outcome-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #9aa5b4;
  margin-bottom: 0.5rem;
}

.dashboard main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(8, 12, 16, 0.85);
  backdrop-filter: blur(12px);
}

.main-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.main-topbar h1 {
  margin: 0;
  font-size: 1.6rem;
}

.main-tabs {
  display: inline-flex;
  background: rgba(16, 23, 29, 0.9);
  border-radius: 999px;
  padding: 0.3rem;
  gap: 0.3rem;
}

.main-tab {
  padding: 0.65rem 1.4rem;
  background: transparent;
  border: none;
  color: #8d98a7;
  border-radius: 999px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.18s ease;
}

.main-tab.active {
  background: linear-gradient(135deg, rgba(21, 196, 126, 0.18), rgba(32, 221, 145, 0.2));
  color: #15f0a8;
}

.view {
  display: none;
  flex: 1;
  overflow-y: auto;
}

.view.active {
  display: flex;
}

.chat {
  flex: 1;
  flex-direction: column;
}

.messages {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  max-width: 72%;
  padding: 1.1rem 1.3rem;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
}

.message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(21, 196, 126, 0.25), rgba(21, 196, 126, 0.18));
  border: 1px solid rgba(21, 196, 126, 0.22);
}

.message.assistant {
  align-self: flex-start;
  background: rgba(17, 24, 31, 0.9);
  border-left: 4px solid rgba(21, 196, 126, 0.45);
}

.chat-form {
  display: flex;
  align-items: flex-end;
  padding: 1.5rem 2rem 2rem;
  gap: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

#chat-input {
  flex: 1 1 auto;
  width: auto;
  min-height: 68px;
  max-height: 220px;
}

.logout {
  margin-top: 0;
  background: rgba(248, 113, 113, 0.85);
  color: #0f1317;
}

.feedback-buttons {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.feedback-buttons .feedback {
  width: 42px;
  padding: 0.4rem 0;
  background: rgba(255, 255, 255, 0.06);
  color: #f0f2f5;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.message.assistant.feedback-up {
  box-shadow: 0 0 0 2px rgba(21, 196, 126, 0.35);
}

.message.assistant.feedback-down {
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.25);
}

.outcome-body p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
  color: #dde2e9;
}

.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 20;
}

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

.modal-content {
  background: rgba(13, 19, 25, 0.96);
  padding: 2rem;
  border-radius: 18px;
  max-width: 480px;
  width: 90%;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #f5f7fa;
  font-size: 1.2rem;
  line-height: 1;
}

.progress-layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.5rem 2rem 2rem;
  width: 100%;
  box-sizing: border-box;
}

.progress-column {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.metrics-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.sliders {
  align-items: end;
}

.slider-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.slider-control input[type="range"] {
  flex: 1;
}

.slider-value {
  font-variant-numeric: tabular-nums;
  min-width: 2ch;
}

.input-with-unit {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(12, 18, 24, 0.9);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 0 0.5rem;
}

.input-with-unit input {
  border: none;
  background: transparent;
  padding: 0.6rem 0.4rem;
  flex: 1;
}

.unit-label {
  font-size: 0.85rem;
  color: #9aa5b4;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.notes-field textarea {
  min-height: 90px;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.form-hint {
  margin: 0;
  font-size: 0.85rem;
  color: #9aa5b4;
  min-height: 1.2em;
}

.chart-card canvas {
  width: 100%;
  height: 280px;
}

.chart-card.hidden {
  display: none;
}

.chart-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.range-toggle,
.unit-toggle {
  display: inline-flex;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.2rem;
}

.range-btn,
.unit-btn {
  border: none;
  background: transparent;
  color: #9aa5b4;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: 0.18s ease;
}

.unit-btn::after {
  content: attr(data-unit);
  display: none;
}

.range-btn.active,
.unit-btn.active {
  background: linear-gradient(135deg, rgba(21, 196, 126, 0.35), rgba(32, 221, 145, 0.38));
  color: #052118;
  font-weight: 600;
}

.chart-card .card-body {
  padding: 0.75rem;
}

.empty-state {
  text-align: center;
  padding: 1.5rem;
  background: rgba(14, 20, 26, 0.9);
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.08);
  font-size: 0.95rem;
  color: #9aa5b4;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(21, 196, 126, 0.92);
  color: #021610;
  padding: 0.9rem 1.25rem;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(21, 196, 126, 0.28);
  z-index: 50;
  font-weight: 600;
  opacity: 0;
  transform: translateY(12px);
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1024px) {
  #app {
    padding: 2rem 1.5rem;
  }
  .dashboard {
    flex-direction: column;
  }
  .dashboard aside {
    width: 100%;
    max-height: none;
    flex-direction: column;
  }
  .dashboard main {
    width: 100%;
  }
  .progress-layout {
    grid-template-columns: 1fr;
  }
  .chart-card canvas {
    height: 240px;
  }
  .messages {
    padding: 1.5rem;
  }
  .chat-form {
    padding: 1.25rem;
  }
}

@media (max-width: 720px) {
  #app {
    padding: 1rem;
    align-items: flex-start;
  }
  .dashboard {
    border-radius: 18px;
  }
  .main-topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .main-tabs {
    width: 100%;
    justify-content: space-between;
  }
  .sidebar-actions {
    flex-direction: column;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .messages {
    padding: 1rem;
  }
  .message {
    max-width: 100%;
  }
  .chat-form {
    flex-direction: column;
    align-items: stretch;
  }
  #chat-input {
    min-height: 120px;
  }
  .chart-card canvas {
    height: 200px;
  }
}

.message.assistant.feedback-down {
  box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.35);
}

.sidebar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

#outcome-btn {
  background: #2563eb;
  color: #f0f2f5;
}

.outcome-history {
  margin-top: 2rem;
}

.outcome-history h3 {
  margin-bottom: 0.75rem;
}

.outcome-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.outcome-item {
  padding: 0.85rem;
  border-radius: 10px;
  background: #182029;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.outcome-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: #9aa5b4;
}

.outcome-body p {
  margin: 0.2rem 0;
  font-size: 0.95rem;
}

.empty-outcome {
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  font-size: 0.9rem;
  color: #94a3b8;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.open {
  display: flex;
}

.modal-content {
  background: #141b22;
  border-radius: 12px;
  padding: 1.5rem;
  width: min(420px, 90vw);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-content h2 {
  margin: 0;
}

.modal-content label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.95rem;
}

.modal-content select,
.modal-content input,
.modal-content textarea {
  background: #0d1318;
  border: 1px solid #1f2a33;
  color: #f0f2f5;
}

.modal-close {
  position: absolute;
  right: 1rem;
  top: 1rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #7a8593;
  width: auto;
  padding: 0;
}

.modal-close:hover {
  color: #f0f2f5;
  transform: none;
}
