/* StackVault shared shell — sidebar (nav + balance) + lean topbar */
:root {
  --bg: #0a0d15;
  --surface: #11151f;
  --surface-2: #151a26;
  --border: #1f2433;
  --sidebar: #0c0f18;
  --accent: #6d5bf5;
  --accent-hover: #5b48ea;
  --accent-soft: rgba(109, 91, 245, 0.1);
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, 0.12);
  --amber: #f6b93b;
  --red: #f66161;
  --text: #e7e9ee;
  --text-mid: #8b91a3;
  --text-dim: #8b91a3;
  --text-faint: #5c6376;
  --font: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --sidebar-width: 232px;
  --topbar-height: 60px;

  /* aliases for page-local skins */
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --panel-3: var(--surface-2);
  --panel-alt: #0d1119;
  --panel-border: var(--border);
  --border-soft: var(--border);
  --purple: var(--accent);
  --purple-soft: var(--accent-soft);
  --text-muted: var(--text-mid);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body.app-shell {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
}

body.app-shell a {
  color: inherit;
  text-decoration: none;
}

body.app-shell button {
  font-family: var(--font);
  cursor: pointer;
}

/* ---------- Sidebar: brand + nav + balance + help ---------- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 6px 22px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  color: #fff;
}

.brand-name {
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-faint);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text-dim);
  transition: background 0.15s, color 0.15s;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: #b3a9fb;
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-spacer {
  flex: 1;
  min-height: 20px;
}

/* Balance lives HERE only — not in the topbar */
.balance-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.balance-label {
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.balance-amount {
  color: var(--green);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
}

.balance-amount span {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  margin-left: 3px;
}

.add-btn {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  border: none;
  flex-shrink: 0;
  line-height: 1;
}

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

.help-box {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.help-box p {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.contact-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 12.5px;
}

.contact-btn:hover {
  background: var(--surface-2);
}

.contact-btn svg {
  width: 14px;
  height: 14px;
}

/* ---------- Content + lean topbar ---------- */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--topbar-height);
  padding: 10px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 13, 21, 0.9);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
}

.menu-toggle svg {
  width: 18px;
  height: 18px;
}

.topbar-left {
  flex: 1;
  min-width: 0;
}

.topbar-left h1 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 1px;
  letter-spacing: -0.01em;
}

.topbar-left .breadcrumb {
  font-size: 12px;
  color: var(--text-faint);
}

.topbar-left .breadcrumb a:hover {
  color: var(--text-mid);
}

.topbar-left .breadcrumb .current {
  color: #9d93f4;
}

.topbar-search {
  flex: 1;
  max-width: 440px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 14px;
}

.topbar-search svg {
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  flex-shrink: 0;
}

.topbar-search input {
  background: none;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 13.5px;
  width: 100%;
  font-family: var(--font);
}

.topbar-search input::placeholder {
  color: var(--text-faint);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

/* User lives HERE only — account + logout menu */
.user-menu {
  position: relative;
}

.top-user {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 5px;
  transition: background 0.15s, border-color 0.15s;
}

.user-menu:hover .top-user,
.user-menu:focus-within .top-user {
  background: var(--surface-2);
  border-color: #2a3142;
}

.top-user .avatar {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.top-user span {
  font-size: 13px;
  font-weight: 600;
}

.top-user svg {
  width: 12px;
  height: 12px;
  color: var(--text-faint);
}

.user-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 168px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  z-index: 50;
}

.user-menu:hover .user-dropdown,
.user-menu:focus-within .user-dropdown {
  display: block;
}

.user-dropdown a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-mid);
}

.user-dropdown a:hover {
  background: var(--surface-2);
  color: var(--text);
}

.user-dropdown a svg {
  width: 14px;
  height: 14px;
}

.main {
  flex: 1;
  padding: 28px 32px 48px;
  min-width: 0;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 35;
}

body.sidebar-open .sidebar-backdrop {
  display: block;
}

@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.45);
  }

  .menu-toggle {
    display: inline-flex;
  }

  .topbar {
    padding: 10px 16px;
  }

  .main {
    padding: 20px 16px 36px;
  }

  .topbar-search {
    display: none;
  }

  .top-user span {
    display: none;
  }
}

/* ---------- Toasts ---------- */
.sv-toast-host {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 32px));
  pointer-events: none;
}

.sv-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-size: 13.5px;
  line-height: 1.45;
}

.sv-toast--in {
  opacity: 1;
  transform: translateY(0);
}

.sv-toast--out {
  opacity: 0;
  transform: translateY(-6px);
}

.sv-toast__icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  margin-top: 1px;
}

.sv-toast--success .sv-toast__icon {
  color: var(--green);
  background: var(--green-soft);
}

.sv-toast--error .sv-toast__icon {
  color: var(--red);
  background: rgba(246, 97, 97, 0.14);
}

.sv-toast--warning .sv-toast__icon {
  color: var(--amber);
  background: rgba(246, 185, 59, 0.14);
}

.sv-toast--info .sv-toast__icon {
  color: var(--accent);
  background: var(--accent-soft);
}

.sv-toast__msg {
  flex: 1;
  min-width: 0;
}

.sv-toast__close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  padding: 0 2px;
  cursor: pointer;
}

.sv-toast__close:hover {
  color: var(--text);
}

/* ---------- Confirm modal ---------- */
.sv-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.sv-modal {
  background: var(--surface, #111319);
  border: 1px solid var(--border, #22252e);
  border-radius: 14px;
  padding: 24px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
}

.sv-modal__title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 650;
  color: var(--text);
}

.sv-modal__body {
  margin: 0 0 20px;
  color: var(--text-mid, #9a9ca6);
  font-size: 14px;
  line-height: 1.5;
}

.sv-modal__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.sv-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.sv-btn--ghost {
  background: transparent;
  color: var(--text-mid);
  border: 1px solid var(--border);
}

.sv-btn--ghost:hover {
  color: var(--text);
  border-color: var(--text-faint);
}

.sv-btn--primary {
  background: var(--accent, #6d5ef8);
  color: #fff;
}

.sv-btn--primary:hover {
  background: var(--accent-hover, #5b48ea);
}

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

.sv-btn--danger:hover {
  filter: brightness(1.05);
}

@media (max-width: 560px) {
  .sv-toast-host {
    top: auto;
    bottom: 18px;
    left: 16px;
    right: 16px;
    max-width: none;
  }
}
