/**
 * Sovereign Path — Stitch design system (horizon_wealth / *_desktop)
 * Light editorial UI: Manrope + Inter, primary #000666, growth #1B6D24
 */

:root {
  --sp-primary: #000666;
  --sp-primary-container: #1a237e;
  --sp-secondary: #1b6d24;
  --sp-secondary-container: #a0f399;
  --sp-secondary-fixed: #a3f69c;
  --sp-on-secondary-fixed: #002204;
  --sp-surface-low: #f3f3f3;
  --sp-surface-high: #e8e8e8;
  --sp-surface-highest: #e2e2e2;
  --sp-surface-lowest: #ffffff;
  --sp-on-surface: #1a1c1c;
  --sp-on-surface-variant: #454652;
  --sp-outline-variant: #c6c5d4;
  --sp-tertiary: #380b00;
  --sp-tertiary-fixed: #ffdbd0;
  --sp-on-tertiary-fixed: #390c00;
  --sp-on-tertiary-fixed-variant: #7b2e12;
  --sp-sidebar-w: 16rem;
  --sp-topbar-h: 4rem;
  --sp-fab-shadow: 0 8px 24px rgba(26, 28, 28, 0.08);

  /* Map legacy app tokens → Stitch (keeps existing components working) */
  --bg: var(--sp-surface-low);
  --bg2: #eeeeee;
  --bgc: var(--sp-surface-lowest);
  --bgh: var(--sp-surface-high);
  --gold: var(--sp-secondary);
  --goldl: #2d8f38;
  --goldd: #145a1a;
  --t1: var(--sp-on-surface);
  --t2: #52525b;
  --t3: #71717a;
  --bd: transparent;
  --bdl: rgba(198, 197, 212, 0.35);
  --green: var(--sp-secondary);
  --red: #ba1a1a;
  --blue: #1e40af;
  --orange: #9a3412;
  --purple: #4338ca;
  --teal: #0f766e;
  --ibg: var(--sp-surface-lowest);
  --ibd: var(--sp-outline-variant);
  --ifocus: var(--sp-primary);
  --radius-sm: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
}

.material-symbols-outlined {
  font-family: 'Material Symbols Outlined', sans-serif;
  font-weight: normal;
  font-style: normal;
  font-size: 1.25rem;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
}
.material-symbols-outlined.filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

html { font-size: 15px; }
body.sp-app {
  font-family: 'Inter', 'Pretendard', 'Noto Sans KR', sans-serif;
  background: var(--sp-surface-low);
  color: var(--sp-on-surface);
  min-height: 100vh;
}

h1, h2, h3, .hdr-logo, .ctitle, .font-headline {
  font-family: 'Manrope', 'Inter', sans-serif;
}

/* ─── Shell ─── */
.sp-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 200;
  width: var(--sp-sidebar-w);
  height: 100vh;
  background: var(--sp-surface-high);
  display: flex;
  flex-direction: column;
  padding: 2rem 0 1.5rem;
  gap: 0.5rem;
  box-shadow: none;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}
.sp-sidebar-brand {
  padding: 0 1.75rem 1.25rem;
}
.sp-sidebar-brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.sp-sidebar-logo {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  background: var(--sp-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sp-sidebar-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sp-primary);
  line-height: 1.2;
}
.sp-sidebar-tag {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  padding-left: 3.25rem;
}

.sp-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}
.sp-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: 1rem;
  padding: 0.75rem 1rem 0.75rem 1rem;
  border-radius: 9999px 0 0 9999px;
  text-decoration: none;
  color: #475569;
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  border: none;
  background: transparent;
  cursor: pointer;
  width: calc(100% - 1rem);
  text-align: left;
}
.sp-nav-item:hover {
  background: var(--sp-surface-low);
  color: var(--sp-primary);
  transform: translateX(3px);
}
.sp-nav-item.on {
  background: var(--sp-surface-lowest);
  color: var(--sp-primary);
  box-shadow: 0 1px 3px rgba(26, 28, 28, 0.06);
}

.sp-sidebar-foot {
  padding: 0 1rem;
  margin-top: auto;
}
.sp-btn-sim {
  width: 100%;
  padding: 1rem 1.25rem;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(135deg, var(--sp-primary) 0%, var(--sp-primary-container) 100%);
  box-shadow: var(--sp-fab-shadow);
  transition: transform 0.15s, box-shadow 0.2s;
}
.sp-btn-sim:hover {
  box-shadow: 0 10px 28px rgba(0, 6, 102, 0.18);
  transform: translateY(-1px);
}
.sp-btn-sim:active { transform: scale(0.98); }

.sp-shell {
  margin-left: var(--sp-sidebar-w);
  min-height: 100vh;
  padding-top: var(--sp-topbar-h);
}

.sp-topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sp-sidebar-w);
  z-index: 150;
  height: var(--sp-topbar-h);
  background: var(--sp-surface-lowest);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.5rem;
  flex-wrap: wrap;
}
.sp-topbar::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--sp-surface-low);
}
.sp-topbar-title {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--sp-primary);
  letter-spacing: -0.02em;
}
.sp-topbar-sub {
  display: none;
}
@media (min-width: 768px) {
  .sp-topbar-sub {
    display: block;
    font-size: 0.7rem;
    color: var(--sp-on-surface-variant);
    margin-top: 2px;
  }
}
.sp-topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.sp-nav-toggle {
  display: none;
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 220;
  width: 2.5rem;
  height: 2.5rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--sp-surface-lowest);
  color: var(--sp-primary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: var(--sp-fab-shadow);
}
.sp-nav-toggle .material-symbols-outlined { font-size: 1.5rem; }

/* Mobile tabs strip */
.sp-tabs-mobile {
  display: none;
  position: sticky;
  top: var(--sp-topbar-h);
  z-index: 140;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(198, 197, 212, 0.25);
  padding: 6px 12px;
  overflow-x: auto;
  gap: 4px;
}
.sp-tabs-mobile .tab {
  background: var(--sp-surface-low);
  color: var(--sp-on-surface-variant);
}
.sp-tabs-mobile .tab.on {
  background: var(--sp-primary);
  color: #fff;
  box-shadow: none;
}

/* FAB */
.sp-fab {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 160;
  width: 3.5rem;
  height: 3.5rem;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, var(--sp-primary) 0%, var(--sp-primary-container) 100%);
  box-shadow: var(--sp-fab-shadow);
  transition: transform 0.2s;
}
.sp-fab:hover { transform: scale(1.05); }
.sp-fab:active { transform: scale(0.95); }
.sp-fab .material-symbols-outlined { font-size: 1.75rem; }

/* Sidebar overlay (mobile) */
.sp-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 190;
  background: rgba(26, 28, 28, 0.35);
  backdrop-filter: blur(2px);
}
.sp-sidebar-backdrop.show { display: block; }

@media (max-width: 900px) {
  .sp-nav-toggle { display: flex; }
  .sp-sidebar {
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
  }
  .sp-sidebar.open {
    transform: translateX(0);
  }
  .sp-shell {
    margin-left: 0;
  }
  .sp-topbar {
    left: 0;
    padding-left: 3.5rem;
  }
  .sp-tabs-mobile {
    display: flex;
  }
  .tabs#main-tabs {
    display: none !important;
  }
}

@media (min-width: 901px) {
  .tabs#main-tabs {
    display: none !important;
  }
}

/* ─── Editorial cards (no harsh borders) ─── */
.card,
.acct-card,
.li-card,
.sc {
  background: var(--sp-surface-lowest);
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(26, 28, 28, 0.06);
  outline: 1px solid rgba(198, 197, 212, 0.12);
  outline-offset: -1px;
}
.card:hover,
.acct-card:hover {
  outline-color: rgba(198, 197, 212, 0.22);
  box-shadow: 0 8px 24px rgba(26, 28, 28, 0.06);
}

.ctitle {
  color: var(--sp-primary);
  font-family: 'Manrope', sans-serif;
}
.ctitle::before {
  background: var(--sp-secondary);
  width: 3px;
  height: 1.25rem;
  border-radius: 2px;
}

/* Main content padding */
.main {
  padding: 1.75rem 1.5rem 5rem;
  max-width: 1440px;
  margin: 0 auto;
}

/* Inputs */
.ai-sel,
.ai-key,
.fi,
.fs,
.hi {
  background: var(--sp-surface-high);
  border: none;
  border-radius: var(--radius-md);
  color: var(--sp-on-surface);
  box-shadow: inset 0 0 0 1px transparent;
}
.ai-sel:focus,
.ai-key:focus,
.fi:focus,
.fs:focus,
.hi:focus {
  box-shadow: 0 0 0 2px rgba(0, 6, 102, 0.15);
  border-color: transparent;
  background: var(--sp-surface-lowest);
}

/* Buttons — primary gradient pills where it fits */
.btn-gold {
  background: linear-gradient(135deg, var(--sp-primary) 0%, var(--sp-primary-container) 100%);
  color: #fff;
  border-radius: 9999px;
  box-shadow: var(--sp-fab-shadow);
}
.btn-gold:hover {
  filter: brightness(1.05);
  box-shadow: 0 10px 28px rgba(0, 6, 102, 0.15);
}
.btn-sec {
  background: var(--sp-surface-highest);
  border: none;
  color: var(--sp-on-surface);
}
.btn-sec:hover {
  background: var(--sp-surface-high);
}
.btn-green {
  background: rgba(27, 109, 36, 0.12);
  color: var(--sp-secondary);
  border: none;
}
.btn-purple {
  background: rgba(67, 56, 202, 0.1);
  border: none;
}
.btn-blue {
  background: rgba(30, 64, 175, 0.1);
  border: none;
}

/* Tables */
.ht th,
.st th {
  background: var(--sp-surface-highest);
  color: var(--sp-on-surface-variant);
  border-bottom: 1px solid rgba(198, 197, 212, 0.35);
}
.ht td,
.st td {
  border-bottom: 1px solid rgba(198, 197, 212, 0.2);
}
.sim-wrap {
  border: none;
  outline: 1px solid rgba(198, 197, 212, 0.2);
  outline-offset: -1px;
  border-radius: var(--radius-md);
  background: var(--sp-surface-lowest);
}

/* Progress */
.pbw {
  background: var(--sp-secondary-container);
  border: none;
}
.pbf {
  background: linear-gradient(90deg, var(--sp-secondary), #2d8f38);
}

/* Alerts — softer */
.al-i {
  background: rgba(30, 64, 175, 0.06);
  border: none;
  outline: 1px solid rgba(30, 64, 175, 0.12);
  color: #1e3a8a;
}
.al-w {
  background: rgba(154, 52, 18, 0.06);
  border: none;
  outline: 1px solid rgba(154, 52, 18, 0.12);
  color: #9a3412;
}
.al-s {
  background: rgba(27, 109, 36, 0.08);
  border: none;
  outline: 1px solid rgba(27, 109, 36, 0.15);
  color: #166534;
}
.al-e {
  background: rgba(186, 26, 26, 0.06);
  border: none;
  outline: 1px solid rgba(186, 26, 26, 0.12);
}

.tcol {
  color: var(--sp-primary);
}
.divcol {
  color: var(--sp-secondary);
}

/* AI panel */
.ai-resp {
  background: var(--sp-surface-low);
  border: none;
  outline: 1px solid rgba(198, 197, 212, 0.2);
}
#ai-resp.ai-resp {
  background: var(--sp-surface-low) !important;
  outline: 1px solid rgba(198, 197, 212, 0.2) !important;
}

.cw {
  background: var(--sp-surface-low) !important;
  border: none !important;
  outline: 1px solid rgba(198, 197, 212, 0.15) !important;
}

input[type='checkbox'] {
  accent-color: var(--sp-primary);
}
input[type='range'] {
  accent-color: var(--sp-secondary);
}
input[type='range']::-webkit-slider-thumb {
  background: var(--sp-secondary);
  box-shadow: 0 1px 4px rgba(27, 109, 36, 0.35);
}

.np-opt.on {
  border-color: var(--sp-primary);
  background: rgba(0, 6, 102, 0.04);
  color: var(--sp-primary);
}

/* Agent chat */
.agent-bubble.user {
  background: rgba(0, 6, 102, 0.06);
  border: 1px solid rgba(0, 6, 102, 0.12);
}
.agent-bubble.assistant {
  background: rgba(27, 109, 36, 0.06);
  border: 1px solid rgba(27, 109, 36, 0.12);
}

/* Scrollbar */
::-webkit-scrollbar-thumb {
  background: var(--sp-outline-variant);
}
