@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Noto+Serif+Devanagari:wght@500;600;700&family=Sora:wght@500;600;700;800&display=swap");

:root {
  --page-bg: #f7f7f3;
  --page-accent: #ece9df;
  --surface: rgba(34, 37, 43, 0.9);
  --surface-soft: rgba(50, 55, 64, 0.82);
  --surface-muted: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.1);
  --text: #f7f5ee;
  --text-soft: rgba(247, 245, 238, 0.72);
  --text-dark: #1e1f22;
  --text-dark-soft: rgba(30, 31, 34, 0.6);
  --green: #38b26d;
  --green-soft: rgba(56, 178, 109, 0.14);
  --red: #d95d5d;
  --red-soft: rgba(217, 93, 93, 0.14);
  --gold: #c89e33;
  --gold-soft: rgba(200, 158, 51, 0.16);
  --blue: #4b89d6;
  --blue-soft: rgba(75, 137, 214, 0.14);
  --shadow: 0 18px 42px rgba(23, 24, 27, 0.08);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text-dark);
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(200, 158, 51, 0.08), transparent 24%),
    linear-gradient(180deg, #ffffff 0%, var(--page-bg) 58%, var(--page-accent) 100%);
}

body {
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(30, 31, 34, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 31, 34, 0.03) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 92%);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.16;
  background-image: url("/assets/ashutrust-bg.svg");
  background-repeat: no-repeat;
  background-position: top center;
  background-size: min(1240px, 92vw);
}

a {
  color: inherit;
}

.page-shell {
  width: min(1520px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
  position: relative;
  z-index: 1;
}

.hidden-node {
  display: none;
}

.panel {
  background: linear-gradient(180deg, var(--surface) 0%, #1f2329 100%);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero-grid,
.workspace-grid,
.analytics-grid,
.status-grid {
  display: grid;
  gap: 18px;
}

.hero-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.78fr);
  margin-bottom: 18px;
}

.status-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.workspace-grid {
  grid-template-columns: minmax(0, 1.42fr) minmax(320px, 0.78fr);
  margin-top: 20px;
}

.analytics-grid {
  grid-template-columns: minmax(0, 1.24fr) minmax(320px, 0.96fr);
  margin-top: 20px;
}

.hero-panel,
.summary-panel,
.settings-panel,
.console-panel,
.analytics-panel,
.events-panel {
  padding: 24px;
}

.brand-wordmark {
  font-family: "Sora", "Manrope", sans-serif;
  font-size: clamp(2.2rem, 3vw, 3.8rem);
  font-weight: 800;
  letter-spacing: -0.08em;
  color: #ffffff;
}

.hero-subtitle {
  margin-top: 6px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 1rem;
  font-weight: 600;
}

.shloka-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.shloka-card {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.shloka-title {
  color: #f7e8b2;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.shloka-body {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.shloka-line {
  font-family: "Noto Serif Devanagari", serif;
  color: #fffef8;
  font-size: 0.98rem;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.summary-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-symbol {
  width: 58px;
  height: 58px;
  object-fit: contain;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.summary-label,
.section-kicker {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 11px;
  font-weight: 800;
  color: #d7c38a;
}

.summary-heading,
.section-title {
  font-family: "Sora", "Manrope", sans-serif;
  letter-spacing: -0.04em;
}

.summary-heading {
  font-size: 1.28rem;
  font-weight: 700;
  color: #ffffff;
}

.section-title {
  margin: 4px 0 0;
  font-size: clamp(1.08rem, 1.3vw, 1.45rem);
  font-weight: 700;
  line-height: 1.2;
}

.section-header,
.settings-group {
  min-width: 0;
}

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

.section-header--compact {
  margin-bottom: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.summary-metric {
  padding: 14px 15px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.summary-metric-label,
.field-label,
.metric-title,
.status-label,
.console-label,
.event-time {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.68);
}

.summary-metric-value {
  margin-top: 8px;
  color: #ffffff;
  font-size: 1.12rem;
  font-weight: 800;
}

.status-panel {
  min-height: 104px;
  padding: 18px 20px;
}

.status-panel--info,
.status-panel--queue,
.status-panel--success {
  background: linear-gradient(180deg, var(--surface-soft) 0%, #242931 100%);
}

.status-value,
.console-box,
.metric-subtitle,
.event-message,
.empty-state {
  color: var(--text);
  line-height: 1.6;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.action-button {
  width: 100%;
  min-height: 56px;
  border: none;
  border-radius: 16px;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

.action-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.action-button--primary {
  color: #ffffff;
  background: linear-gradient(135deg, #4b89d6 0%, #2f6db7 100%);
}

.action-button--success {
  color: #ffffff;
  background: linear-gradient(135deg, #42bd77 0%, #2f9a60 100%);
}

.action-button--danger {
  color: #ffffff;
  background: linear-gradient(135deg, #e36b6b 0%, #c34e4e 100%);
}

.action-button--danger-soft {
  color: #ffffff;
  background: linear-gradient(135deg, #8f4751 0%, #70373f 100%);
}

.action-button--accent {
  color: #1e1f22;
  background: linear-gradient(135deg, #f0ca6b 0%, #d7ac41 100%);
}

.action-button--neutral {
  color: #ffffff;
  background: linear-gradient(135deg, #4d5562 0%, #39414e 100%);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.metric-card {
  min-height: 142px;
  padding: 18px;
  border-radius: 22px;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.metric-card--blue {
  background: linear-gradient(180deg, rgba(45, 67, 95, 0.95) 0%, rgba(38, 53, 76, 0.95) 100%);
}

.metric-card--green {
  background: linear-gradient(180deg, rgba(40, 82, 56, 0.96) 0%, rgba(33, 65, 46, 0.96) 100%);
}

.metric-card--red {
  background: linear-gradient(180deg, rgba(92, 47, 47, 0.96) 0%, rgba(73, 38, 38, 0.96) 100%);
}

.metric-card--gold {
  background: linear-gradient(180deg, rgba(86, 71, 34, 0.96) 0%, rgba(70, 58, 29, 0.96) 100%);
}

.metric-value {
  margin-top: 10px;
  font-size: 1.86rem;
  font-weight: 800;
}

.metric-card--blue .metric-value {
  color: #85b9ff;
}

.metric-card--green .metric-value {
  color: #8cf0b5;
}

.metric-card--red .metric-value {
  color: #ffaaaa;
}

.metric-card--gold .metric-value {
  color: #ffd87a;
}

.metric-subtitle {
  margin-top: 10px;
  color: var(--text-soft);
  font-size: 13px;
}

.settings-group {
  margin-top: 18px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-group:first-of-type {
  margin-top: 0;
}

.settings-group-title {
  margin-bottom: 14px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.field {
  min-width: 0;
}

/* ─── Text inputs ─────────────────────────────────────────────────────────── */

.app-input {
  min-height: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  background: #202732 !important;
  color: #f7f5ee !important;
  box-shadow: none;
  width: 100%;
  padding: 0 14px;
  outline: none;
}

.app-input,
.app-input::placeholder {
  color: #f7f5ee;
}

input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type=number] {
  -moz-appearance: textfield;
}

.app-input:focus {
  border-color: rgba(75, 137, 214, 0.58) !important;
  box-shadow: 0 0 0 4px rgba(75, 137, 214, 0.18) !important;
}

/* ─── Dropdowns: react-select v1 / legacy Dash (kept for back-compat) ──────── */

.app-select .Select-control {
  min-height: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  background: #202732 !important;
  color: #f7f5ee !important;
  box-shadow: none;
  display: flex;
  align-items: center;
}

.app-select.is-focused:not(.is-open) > .Select-control,
.app-select.is-open > .Select-control {
  border-color: rgba(75, 137, 214, 0.58) !important;
  box-shadow: 0 0 0 4px rgba(75, 137, 214, 0.18) !important;
}

.app-select .Select-input > input,
.app-select .Select-placeholder,
.app-select .Select-value,
.app-select .Select-value-label,
.app-select .Select-single-value,
.app-select .Select-arrow,
.app-select .Select-arrow-zone,
.app-select .Select-clear-zone,
.app-select .Select.has-value > .Select-control .Select-value,
.app-select .Select.has-value > .Select-control .Select-value .Select-value-label,
.app-select.has-value.Select--single > .Select-control .Select-value .Select-value-label,
.app-select.has-value.is-pseudo-focused.Select--single > .Select-control .Select-value .Select-value-label,
.app-select .Select--single > .Select-control .Select-value,
.app-select .Select--single > .Select-control .Select-value .Select-value-label {
  color: #f7f5ee !important;
  opacity: 1 !important;
}

.app-select .Select-value {
  max-width: calc(100% - 32px);
}

.app-select .Select-placeholder {
  color: rgba(247, 245, 238, 0.62) !important;
}

.app-select .Select-menu-outer {
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 16px;
  background: #202732 !important;
  color: #f7f5ee !important;
  z-index: 9999 !important;
  overflow: hidden;
}

.app-select .Select-menu {
  background: #202732 !important;
}

.app-select .Select-option {
  color: #f7f5ee !important;
  background: #202732 !important;
}

.app-select .Select-option.is-focused {
  background: #2a3443 !important;
}

.app-select .Select-option.is-selected {
  background: #35506f !important;
}

/* ─── Dropdowns: react-select v5 (Dash ≥ 2.0) ─────────────────────────────
   Dash 2.x switched to react-select v5 which uses BEM-style class names
   prefixed with "Select__" instead of "Select-".  Without these rules the
   selected value is invisible (dark text on dark background) and the menu
   panel shows the page light background instead of the dark surface.
   ─────────────────────────────────────────────────────────────────────────── */

.app-select .Select__control {
  min-height: 46px;
  border-radius: 14px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  background: #202732 !important;
  box-shadow: none !important;
  cursor: pointer;
}

.app-select .Select__control:hover {
  border-color: rgba(255, 255, 255, 0.22) !important;
}

.app-select .Select__control--is-focused,
.app-select .Select__control--menu-is-open {
  border-color: rgba(75, 137, 214, 0.58) !important;
  box-shadow: 0 0 0 4px rgba(75, 137, 214, 0.18) !important;
}

.app-select .Select__value-container {
  padding: 0 12px;
}

/* ── This is the critical fix: selected text was invisible (dark on dark) ── */
.app-select .Select__single-value {
  color: #f7f5ee !important;
  opacity: 1 !important;
  font-size: 14px;
  font-weight: 600;
}

.app-select .Select__placeholder {
  color: rgba(247, 245, 238, 0.52) !important;
  font-size: 14px;
}

.app-select .Select__input-container {
  color: #f7f5ee !important;
  margin: 0;
  padding: 0;
}

.app-select .Select__input-container input {
  color: #f7f5ee !important;
}

.app-select .Select__indicator {
  color: rgba(247, 245, 238, 0.6) !important;
  padding: 0 8px;
}

.app-select .Select__indicator:hover {
  color: #f7f5ee !important;
}

.app-select .Select__indicator-separator {
  background-color: rgba(255, 255, 255, 0.12) !important;
}

.app-select .Select__menu {
  background: #202732 !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 16px !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45) !important;
  z-index: 9999 !important;
  overflow: hidden;
  margin-top: 6px !important;
}

.app-select .Select__menu-list {
  background: #202732 !important;
  padding: 6px !important;
}

.app-select .Select__option {
  color: #f7f5ee !important;
  background: transparent !important;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 12px !important;
  cursor: pointer;
}

.app-select .Select__option--is-focused {
  background: #2a3443 !important;
  color: #ffffff !important;
}

.app-select .Select__option--is-selected {
  background: #35506f !important;
  color: #ffffff !important;
  font-weight: 700;
}

.app-select .Select__option--is-selected.Select__option--is-focused {
  background: #3d5c80 !important;
}

.app-select .Select__menu-notice--no-options {
  color: rgba(247, 245, 238, 0.5) !important;
  background: #202732 !important;
  font-size: 13px;
}

/* ─── Save settings toast ─────────────────────────────────────────────────── */

.save-toast {
  margin-top: 14px;
  padding: 12px 18px;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 700;
  transition: opacity 0.3s ease;
}

.save-toast--hidden {
  display: none;
}

.save-toast--ok {
  display: block;
  background: rgba(56, 178, 109, 0.16);
  border: 1px solid rgba(56, 178, 109, 0.35);
  color: #8cf0b5;
}

.save-toast--error {
  display: block;
  background: rgba(217, 93, 93, 0.16);
  border: 1px solid rgba(217, 93, 93, 0.35);
  color: #ffaaaa;
}

.flag-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.flag-item {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 0 !important;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.flag-checkbox {
  accent-color: #4b89d6;
}

.console-section + .console-section {
  margin-top: 18px;
}

.console-box {
  margin-top: 8px;
  min-height: 112px;
  padding: 16px;
  border-radius: 18px;
}

.console-box--info {
  background: rgba(75, 137, 214, 0.12);
  border: 1px solid rgba(75, 137, 214, 0.22);
}

.console-box--danger {
  background: rgba(217, 93, 93, 0.12);
  border: 1px solid rgba(217, 93, 93, 0.22);
}

.chart {
  min-height: 420px;
}

.events-feed {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event-card {
  padding: 15px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.event-card--info {
  background: var(--blue-soft);
}

.event-card--success {
  background: var(--green-soft);
}

.event-card--warning {
  background: var(--gold-soft);
}

.event-card--danger {
  background: var(--red-soft);
}

.event-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.positions-wrap {
  overflow-x: auto;
}

.positions-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.positions-head-cell {
  padding: 14px 12px;
  text-align: left;
  color: rgba(255, 255, 255, 0.72);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.positions-row {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.positions-cell {
  padding: 14px 12px;
  color: #ffffff;
  font-size: 0.94rem;
}

.positions-cell--instrument {
  min-width: 220px;
  overflow-wrap: anywhere;
}

.pnl-positive {
  color: #8cf0b5;
  font-weight: 800;
}

.pnl-negative {
  color: #ffaaaa;
  font-weight: 800;
}

.pnl-flat {
  color: #ffffff;
  font-weight: 800;
}

.empty-state {
  padding: 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.1);
}

@media (max-width: 1180px) {
  .hero-grid,
  .workspace-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    padding-top: 16px;
  }

  .status-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel,
  .summary-panel,
  .settings-panel,
  .console-panel,
  .analytics-panel,
  .events-panel {
    padding: 20px;
  }

  .shloka-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .summary-grid,
  .field-grid,
  .flag-list,
  .actions-grid {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 1.55rem;
  }
}