/* Simplefolio — Apple-inspired Light & Dark Design System */

:root {
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface-elevated: #FFFFFF;
  --surface-muted: #F2F2F7;
  --glass: rgba(245, 245, 247, 0.78);
  --border: rgba(0, 0, 0, 0.07);
  --border-strong: rgba(0, 0, 0, 0.13);
  --text: #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary: #86868B;
  --accent: #007AFF;
  --accent-hover: #0066D6;
  --accent-soft: rgba(0, 122, 255, 0.11);
  --green: #28A745;
  --green-soft: rgba(52, 199, 89, 0.14);
  --amber: #D97706;
  --amber-soft: rgba(255, 149, 0, 0.14);
  --red: #E53935;
  --red-soft: rgba(255, 59, 48, 0.12);
  --seg-bg: rgba(118, 118, 128, 0.12);
  --seg-active: #FFFFFF;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.035);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-menu: 0 12px 36px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.06);
  --shadow-seg: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 1px rgba(0, 0, 0, 0.05);
  --radius-xl: 20px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 9px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #1C1C1E;
    --surface-elevated: #2C2C2E;
    --surface-muted: #242426;
    --glass: rgba(0, 0, 0, 0.72);
    --border: rgba(255, 255, 255, 0.09);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text: #F5F5F7;
    --text-secondary: #98989D;
    --text-tertiary: #636366;
    --accent: #0A84FF;
    --accent-hover: #409CFF;
    --accent-soft: rgba(10, 132, 255, 0.18);
    --green: #30D158;
    --green-soft: rgba(48, 209, 88, 0.16);
    --amber: #FF9F0A;
    --amber-soft: rgba(255, 159, 10, 0.16);
    --red: #FF453A;
    --red-soft: rgba(255, 69, 58, 0.16);
    --seg-bg: rgba(118, 118, 128, 0.24);
    --seg-active: #3A3A3C;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.28);
    --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.65);
    --shadow-menu: 0 16px 40px rgba(0, 0, 0, 0.6);
    --shadow-seg: 0 1px 4px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #1C1C1E;
  --surface-elevated: #2C2C2E;
  --surface-muted: #242426;
  --glass: rgba(0, 0, 0, 0.72);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #F5F5F7;
  --text-secondary: #98989D;
  --text-tertiary: #636366;
  --accent: #0A84FF;
  --accent-hover: #409CFF;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --green: #30D158;
  --green-soft: rgba(48, 209, 88, 0.16);
  --amber: #FF9F0A;
  --amber-soft: rgba(255, 159, 10, 0.16);
  --red: #FF453A;
  --red-soft: rgba(255, 69, 58, 0.16);
  --seg-bg: rgba(118, 118, 128, 0.24);
  --seg-active: #3A3A3C;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.28);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, 0.65);
  --shadow-menu: 0 16px 40px rgba(0, 0, 0, 0.6);
  --shadow-seg: 0 1px 4px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
}

.num {
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

/* Boot Loader */
.boot-loader {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinning svg {
  animation: spin 0.8s linear infinite;
}

/* Auth / Setup Screens */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 36px 32px 32px;
  box-shadow: var(--shadow-card);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-icon {
  width: 56px;
  height: 56px;
  border-radius: 15px;
  background: linear-gradient(145deg, #4CE06E 0%, #22B455 52%, #0D7A3E 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  overflow: hidden;
  user-select: none;
  box-shadow:
    0 10px 26px rgba(18, 148, 68, 0.34),
    0 2px 6px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.brand-icon svg.sf-logo {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-icon.small {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  box-shadow:
    0 3px 10px rgba(18, 148, 68, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.brand-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.auth-title {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.auth-sub {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-secondary);
  text-align: center;
}

.qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.qr-frame {
  background: #FFFFFF;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  display: inline-flex;
}

.qr-frame img {
  width: 176px;
  height: 176px;
  display: block;
}

.secret-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  background: var(--surface-muted);
  padding: 6px 12px;
  border-radius: 999px;
  user-select: all;
}

/* Form Elements */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input, .select {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  background: var(--surface-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.input:focus, .select:focus {
  background: var(--surface-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input.totp-input {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums;
}

.input.compact {
  height: 34px;
  padding: 0 10px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.select.compact {
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
  border-radius: 8px;
  width: auto;
}

.ticker-lookup-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ticker-lookup-row .input {
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.quote-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  background: var(--surface-muted);
  font-size: 13.5px;
  margin-bottom: 14px;
}

.quote-preview.ok {
  background: var(--green-soft);
  color: var(--green);
}

.quote-preview.err {
  background: var(--red-soft);
  color: var(--red);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 18px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.error-banner {
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  border: none;
  font-size: 14.5px;
  font-weight: 500;
  transition: background 0.15s, transform 0.08s, opacity 0.15s;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--border-strong);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  height: 32px;
  padding: 0 10px;
  font-size: 13.5px;
  border-radius: 8px;
}

.btn-ghost:hover {
  background: var(--accent-soft);
}

.btn-danger {
  background: var(--red-soft);
  color: var(--red);
}

.btn-danger:hover {
  background: var(--red);
  color: #fff;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 9px;
}

.btn-full {
  width: 100%;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover:not(:disabled) {
  background: var(--seg-bg);
  color: var(--text);
}

.icon-btn.active {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn.active:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.icon-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.icon-btn.danger:hover:not(:disabled) {
  background: var(--red-soft);
  color: var(--red);
}

/* Add Dropdown Menu (Apple Popover) */
.menu-anchor {
  position: relative;
  display: inline-block;
}

.popover-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  box-shadow: var(--shadow-menu);
  z-index: 60;
  animation: slideUp 0.14s cubic-bezier(0.22, 1, 0.36, 1);
}

.popover-item {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 9px 11px;
  border: none;
  border-radius: 9px;
  background: transparent;
  text-align: left;
  transition: background 0.12s;
}

.popover-item:hover {
  background: var(--accent-soft);
}

.popover-item strong {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.popover-item span {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Sticky Frosted Top Bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--glass);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1060px;
  margin: 0 auto;
  height: 58px;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 9px;
}

.brand-name {
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

/* Apple Segmented Control */
.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--seg-bg);
  border-radius: 10px;
  gap: 2px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 6px 16px;
  border-radius: 7.5px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.18s, color 0.18s, box-shadow 0.18s;
  white-space: nowrap;
}

.segmented button.active {
  background: var(--seg-active);
  color: var(--text);
  box-shadow: var(--shadow-seg);
}

.segmented.compact button {
  padding: 5px 11px;
  font-size: 12.5px;
}

/* Main Content Container */
.main {
  max-width: 1060px;
  margin: 0 auto;
  padding: 26px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
}

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

.card-title {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

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

/* Hero Card */
.hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.hero-value {
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.08;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.hero-ccy {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 9px;
  color: var(--text-secondary);
  font-size: 13px;
  flex-wrap: wrap;
}

.fx-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 12.5px;
  color: var(--text-secondary);
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  border: none;
}

.status-badge.ok {
  background: var(--green-soft);
  color: var(--green);
}

.status-badge.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* Stacked Allocation Ribbon inside Hero */
.ribbon-wrap {
  margin-top: 22px;
}

.ribbon-bar {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  gap: 2px;
  background: var(--surface-muted);
}

.ribbon-seg {
  height: 100%;
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.ribbon-seg:first-child { border-radius: 999px 0 0 999px; }
.ribbon-seg:last-child { border-radius: 0 999px 999px 0; }

.ribbon-legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.legend-items {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

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

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Allocation List */
.alloc-list {
  display: flex;
  flex-direction: column;
}

.alloc-row {
  display: grid;
  grid-template-columns: 150px 1fr 112px 128px 115px;
  align-items: center;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.alloc-row:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.alloc-name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 500;
}

.alloc-bar-track {
  position: relative;
  height: 8px;
  background: var(--surface-muted);
  border-radius: 999px;
  overflow: visible;
}

.alloc-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.alloc-target-mark {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: var(--text);
  border-radius: 2px;
  opacity: 0.65;
}

.alloc-pcts {
  text-align: right;
  font-size: 13.5px;
}

.alloc-pcts .muted {
  color: var(--text-tertiary);
  font-size: 12px;
}

.alloc-drift {
  text-align: right;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

.drift-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.drift-pill.ok {
  color: var(--text-secondary);
  background: transparent;
  padding: 0;
}

.drift-pill.over {
  background: var(--amber-soft);
  color: var(--amber);
}

.drift-pill.under {
  background: var(--accent-soft);
  color: var(--accent);
}

.drift-cad {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.alloc-val {
  text-align: right;
  font-weight: 500;
  font-size: 14.5px;
}

/* Holdings Table */
.table-wrap {
  overflow-x: auto;
  margin: 0 -8px;
  padding: 0 8px;
}

table.holdings-table {
  width: 100%;
  border-collapse: collapse;
}

.holdings-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 10px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.holdings-table th.right,
.holdings-table td.right {
  text-align: right;
}

.holdings-table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.holdings-table tr:last-child td {
  border-bottom: none;
}

.holding-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
}

.holding-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1.5px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.pill.ticker {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.pill.locked {
  color: var(--text-tertiary);
}

.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  white-space: nowrap;
}

.inline-trigger {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 4px 7px;
  margin: -4px -7px;
  transition: background 0.14s, border-color 0.14s;
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.inline-trigger:hover {
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

.inline-input {
  width: 112px;
  height: 30px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1.5px solid var(--accent);
  background: var(--surface-elevated);
  text-align: right;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.sub-val {
  display: block;
  font-size: 11.5px;
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* Rebalance Screen */
.rebal-header {
  display: flex;
  align-items: center;
  justify-content: center;
}

.rebal-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.cash-input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.big-amount-wrap {
  display: inline-flex;
  align-items: center;
  background: var(--surface-muted);
  border: 1.5px solid transparent;
  border-radius: 14px;
  padding: 0 14px;
  height: 48px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.big-amount-wrap:focus-within {
  background: var(--surface-elevated);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.big-amount-wrap span {
  font-size: 20px;
  font-weight: 500;
  color: var(--text-tertiary);
  margin-right: 4px;
}

.big-amount-wrap input {
  width: 140px;
  border: none;
  background: transparent;
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.toggle-group {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* Apple Switch */
.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.switch {
  position: relative;
  width: 42px;
  height: 24px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--seg-bg);
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}

.switch:checked {
  background: var(--green);
}

.switch:checked::after {
  transform: translateX(18px);
}

.mini-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.mini-input-wrap input {
  width: 72px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--surface-muted);
  border: 1px solid transparent;
  text-align: right;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.mini-input-wrap input:focus {
  border-color: var(--accent);
}

/* Action Plan Trade Cards */
.trade-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trade-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
}

.trade-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.trade-cat-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.action-tag {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 999px;
}

.action-tag.buy {
  background: var(--green-soft);
  color: var(--green);
}

.action-tag.sell {
  background: var(--red-soft);
  color: var(--red);
}

.trade-amount-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 18px;
  font-weight: 600;
}

.trade-amount-head .sub {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.trade-lines {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trade-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  flex-wrap: wrap;
}

.trade-line-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trade-line-right {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: right;
}

.shares-pill {
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
}

/* Before / After Table */
.ba-row {
  display: grid;
  grid-template-columns: 140px 1fr 165px 95px;
  align-items: center;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.ba-row:last-child {
  border-bottom: none;
}

.ba-bars {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ba-track {
  position: relative;
  height: 6px;
  background: var(--surface-muted);
  border-radius: 999px;
}

.ba-track.before .alloc-bar-fill {
  opacity: 0.35;
}

/* Empty Balanced State */
.balanced-state {
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.check-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* What-If Grid */
.whatif-grid {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(320px, 1.15fr);
  gap: 20px;
  align-items: start;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.slider-group:last-child {
  border-bottom: none;
}

.slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
}

.slider-head strong {
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.sim-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.sim-delta {
  font-size: 14px;
  font-weight: 600;
}

.sim-delta.pos { color: var(--green); }
.sim-delta.neg { color: var(--red); }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.14s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow-modal);
  animation: slideUp 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal.wide {
  max-width: 560px;
}

@keyframes slideUp {
  from { transform: translateY(10px) scale(0.985); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.quick-row {
  display: grid;
  grid-template-columns: 1fr 130px;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.quick-row:last-child {
  border-bottom: none;
}

.target-edit-head,
.target-edit-row {
  display: grid;
  grid-template-columns: 26px 1fr 78px 74px 32px;
  gap: 8px;
  align-items: center;
}

.target-edit-head {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.target-edit-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.settings-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.settings-section:first-of-type {
  padding-top: 0;
}

.settings-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-section h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
  animation: slideUp 0.2s ease;
}

.toast.error {
  background: var(--red);
  color: #fff;
}

/* Responsive */
@media (max-width: 780px) {
  .topbar-inner {
    grid-template-columns: auto 1fr auto;
    padding: 0 14px;
  }
  .brand-name {
    display: none;
  }
  .main {
    padding: 18px 14px 52px;
  }
  .card {
    padding: 18px 16px;
    border-radius: 18px;
  }
  .hero-value {
    font-size: 34px;
  }
  .alloc-row {
    grid-template-columns: 115px 1fr 96px;
    gap: 10px;
  }
  .alloc-bar-track, .alloc-val {
    display: none;
  }
  .ba-row {
    grid-template-columns: 110px 1fr 80px;
  }
  .ba-bars {
    display: none;
  }
  .whatif-grid {
    grid-template-columns: 1fr;
  }
  .form-grid-2 {
    grid-template-columns: 1fr;
  }
}
