:root {
  --bg: #eff4f1;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --panel-muted: #f5f8f6;
  --ink: #112119;
  --muted: #5f7367;
  --line: rgba(17, 33, 25, 0.08);
  --accent: #18382b;
  --accent-soft: #d9efe3;
  --gain: #168a52;
  --gain-soft: rgba(22, 138, 82, 0.12);
  --loss: #cc4d42;
  --loss-soft: rgba(204, 77, 66, 0.12);
  --warning: #bf8a18;
  --shadow: 0 24px 60px rgba(19, 39, 29, 0.08);
  --radius: 26px;
  --radius-sm: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(130, 186, 155, 0.22), transparent 26%),
    radial-gradient(circle at right top, rgba(23, 56, 43, 0.08), transparent 24%),
    linear-gradient(180deg, #f8fbf9 0%, var(--bg) 100%);
}

body.auth-only {
  overflow: hidden;
}

.app-hidden {
  display: none;
}

button,
input,
select {
  font: inherit;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: auto;
  background:
    radial-gradient(circle at top left, rgba(130, 186, 155, 0.22), transparent 26%),
    radial-gradient(circle at right top, rgba(23, 56, 43, 0.08), transparent 24%),
    linear-gradient(180deg, #f8fbf9 0%, var(--bg) 100%);
}

.auth-card {
  width: min(980px, 100%);
  padding: 28px;
  border-radius: 32px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.72);
}

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

.auth-single {
  grid-template-columns: 1fr;
}

.auth-toggle {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 22px;
  padding: 6px;
  border-radius: 18px;
  background: var(--panel-muted);
  border: 1px solid var(--line);
}

.auth-toggle-button {
  border: 0;
  padding: 12px 18px;
  border-radius: 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.auth-toggle-button.is-active {
  background: var(--accent);
  color: #fff;
}

.auth-form {
  padding: 22px;
  border-radius: 24px;
  background: var(--panel-muted);
  border: 1px solid var(--line);
  display: grid;
  gap: 14px;
}

.auth-panel {
  display: none;
}

.auth-panel.is-active {
  display: grid;
}

.backend-form {
  margin-top: 22px;
}

.backend-form .button-secondary {
  background: var(--accent);
  color: #ffffff;
}

.backend-status {
  margin: 0;
  color: var(--muted);
}

.backend-status.is-ready {
  color: var(--gain);
  font-weight: 700;
}

.auth-form h2,
.auth-copy h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

.muted-dark {
  color: var(--muted);
}

.auth-message {
  margin: 16px 4px 0;
}

.auth-inline-message {
  margin: 0;
  min-height: 20px;
}

.auth-switch {
  margin: 0;
  color: var(--muted);
}

.text-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px 22px;
  background: rgba(16, 34, 26, 0.96);
  color: #f5faf6;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.account-chip {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
}

.account-chip strong {
  font-size: 0.95rem;
}

.brand-block h1,
.topbar h2,
.panel-head h3,
.summary-card strong {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

.muted,
.brand-block .muted {
  color: rgba(245, 250, 246, 0.72);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-weight: 800;
  color: #7ca38f;
}

.nav-list {
  display: grid;
  gap: 10px;
}

.nav-item,
.button {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.nav-item {
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  text-align: left;
  padding: 14px 16px;
  font-weight: 600;
}

.nav-item.is-active,
.nav-item:hover {
  background: #f5faf6;
  color: var(--accent);
  transform: translateX(4px);
}

.sidebar-actions {
  margin-top: auto;
  display: grid;
  gap: 10px;
}

.button {
  padding: 13px 16px;
  font-weight: 700;
}

.button-primary {
  background: var(--accent);
  color: #fff;
}

.button-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #f5faf6;
}

.main-content {
  padding: 28px;
}

.topbar,
.summary-grid,
.content-grid,
.analytics-grid,
.rebalancing-grid {
  display: grid;
  gap: 18px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 20px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.currency-switch {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.currency-switch span {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.currency-switch select {
  min-width: 110px;
  padding: 10px 12px;
}

.status-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: var(--shadow);
}

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

.summary-card,
.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.summary-card {
  padding: 20px;
  display: grid;
  gap: 8px;
}

.summary-card span,
.summary-card small,
.panel-head,
label span,
th,
.form-message,
.insight-item small {
  color: var(--muted);
}

.summary-card strong {
  font-size: 1.7rem;
}

.content-grid {
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
}

.content-main,
.content-side,
.analytics-grid,
.rebalancing-grid {
  display: grid;
  gap: 18px;
}

.panel {
  padding: 22px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.legend-row {
  display: flex;
  gap: 16px;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.gain {
  background: var(--gain);
}

.loss {
  background: var(--loss);
}

.view-section {
  display: none;
}

.view-section.is-active {
  display: block;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.94rem;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.holding-row.is-clickable {
  cursor: pointer;
}

.holding-row.is-clickable:hover td {
  background: rgba(24, 56, 43, 0.03);
}

.lot-row td {
  background: rgba(24, 56, 43, 0.035);
}

.lot-row td:first-child {
  padding-left: 28px;
}

.asset-name {
  font-weight: 700;
}

.expand-indicator {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 700;
}

.asset-sub {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 700;
}

.pill.gain {
  background: var(--gain-soft);
  color: var(--gain);
}

.pill.loss {
  background: var(--loss-soft);
  color: var(--loss);
}

.pill.neutral {
  background: rgba(24, 56, 43, 0.08);
  color: var(--accent);
}

.form-grid,
.targets-grid {
  display: grid;
  gap: 16px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.transaction-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 8px;
}

input,
select {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(24, 56, 43, 0.14);
  border-color: rgba(24, 56, 43, 0.22);
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.row-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.table-action {
  border: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(24, 56, 43, 0.08);
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
}

.form-message {
  min-height: 20px;
}

.analytics-grid,
.rebalancing-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-panel {
  grid-column: 1 / -1;
}

canvas {
  width: 100%;
  max-height: 320px;
}

.inner-panel {
  background: var(--panel-muted);
  box-shadow: none;
}

.asset-manager-panel {
  margin-top: 18px;
}

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

.allocation-overview,
.insight-list,
.snapshot-report,
.simulator-results {
  display: grid;
  gap: 12px;
}

.asset-manager-item {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.asset-manager-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.table-action.is-danger {
  background: rgba(204, 77, 66, 0.12);
  color: var(--loss);
}

.allocation-item,
.insight-item,
.snapshot-card,
.scenario-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--panel-muted);
  border: 1px solid var(--line);
}

.allocation-top,
.insight-top,
.snapshot-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.allocation-bar {
  margin-top: 10px;
  height: 9px;
  border-radius: 999px;
  background: rgba(24, 56, 43, 0.08);
  overflow: hidden;
}

.allocation-fill {
  height: 100%;
  background: linear-gradient(90deg, #2c6b4d, #5fb282);
  border-radius: 999px;
}

.empty-state {
  padding: 20px;
  border-radius: 18px;
  border: 1px dashed rgba(24, 56, 43, 0.18);
  background: rgba(24, 56, 43, 0.02);
  color: var(--muted);
}

.positive {
  color: var(--gain);
}

.negative {
  color: var(--loss);
}

.warning {
  color: var(--warning);
}

@media (max-width: 1180px) {
  .auth-grid,
  .app-shell,
  .content-grid,
  .summary-grid,
  .analytics-grid,
  .rebalancing-grid,
  .transaction-grid,
  .targets-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .auth-card,
  .sidebar,
  .main-content {
    padding: 20px;
  }

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

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