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

:root {
  --bg:           #0b0d12;
  --bg-2:         #0e1117;
  --surface:      #161921;
  --surface-2:    #1e2330;
  --surface-3:    #252b3a;
  --border:       #2a2f3e;
  --border-soft:  rgba(42,47,62,0.5);
  --primary:      #6c63ff;
  --primary-h:    #8880ff;
  --accent:       #22d3ee;
  --success:      #22c55e;
  --danger:       #ef4444;
  --warning:      #f59e0b;
  --text:         #e2e8f0;
  --text-muted:   #8892a4;
  --text-dim:     #5b6478;
  --radius:       12px;
  --radius-sm:    6px;
}

body {
  background: radial-gradient(ellipse at top, var(--bg-2) 0%, var(--bg) 60%);
  background-attachment: fixed;
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

/* ── Header ── */
.site-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem;
}
.brand h1 { font-size: 1.75rem; font-weight: 700; }
.brand h1 .version { color: var(--primary); font-size: 0.85rem; vertical-align: super; }
.subtitle { color: var(--text-muted); margin-top: 0.2rem; font-size: 0.9rem; }
.auth-bar {
  display: flex; align-items: center; gap: 0.6rem;
  flex-wrap: wrap;
}
#principal-display {
  font-family: monospace; font-size: 0.75rem;
  color: var(--text-muted); background: var(--surface-2);
  padding: 0.3rem 0.6rem; border-radius: var(--radius-sm);
  max-width: 200px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* ── Account card ── */
.account-card {
  background: linear-gradient(135deg, var(--surface) 0%, var(--bg-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.account-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.85rem;
}
.account-header h3 {
  font-size: 0.85rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 1px; font-weight: 600;
}
.account-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem 1.25rem;
  align-items: center;
}
.account-stat { display: contents; }
.account-label {
  font-size: 0.78rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.account-value { font-weight: 700; font-size: 1.15rem; color: var(--success); }
.account-principal {
  font-family: monospace; font-size: 0.78rem;
  background: var(--surface-2); padding: 0.3rem 0.55rem;
  border-radius: 4px; word-break: break-all; color: var(--text);
}
.account-help {
  margin-top: 0.85rem; padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.85rem; color: var(--text-muted);
}
.account-help summary {
  cursor: pointer; color: var(--primary); user-select: none;
  font-weight: 500;
}
.account-help ol { margin: 0.6rem 0 0.4rem 1.25rem; }
.account-help li { margin: 0.2rem 0; }
.account-help a { color: var(--primary); text-decoration: none; }
.account-help a:hover { text-decoration: underline; }

/* ── Intro card ── */
.intro-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}
.intro-card strong { color: var(--text); }

/* ── Vaults section ── */
.vaults-section { margin-bottom: 1.5rem; }
.vaults-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 1rem; padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-soft);
}
.vaults-header h2 { font-size: 1.4rem; font-weight: 700; }

/* ── Vault card (the canisterization) ── */
.vault-card {
  background:
    linear-gradient(180deg, rgba(108,99,255,0.04) 0%, transparent 30%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
  position: relative;
}
.vault-card::before {
  content: ""; position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.vault-card-header {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(108,99,255,0.025);
  flex-wrap: wrap;
}
.vault-id-badge {
  font-family: monospace; font-weight: 700; font-size: 0.95rem;
  background: var(--surface-3); color: var(--primary);
  padding: 0.4rem 0.65rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.vault-title-block { flex: 1; min-width: 200px; }
.vault-title-block h3 { font-size: 1.15rem; font-weight: 600; margin-bottom: 0.35rem; }
.vault-pair {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.85rem;
}
.token-pill {
  display: inline-block; padding: 0.15rem 0.55rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; font-weight: 500; font-size: 0.78rem;
}
.token-icp    { color: #29abe2; border-color: rgba(41,171,226,0.3); }
.token-ckusdc { color: #2775ca; border-color: rgba(39,117,202,0.3); }
.token-ckbtc  { color: #f7931a; border-color: rgba(247,147,26,0.3); }
.token-cketh  { color: #627eea; border-color: rgba(98,126,234,0.3); }
.rotation-arrow { color: var(--text-muted); font-size: 1rem; }

.vault-card-body { padding: 1.25rem 1.5rem 1.5rem; }

.vault-strategy-row {
  display: flex; justify-content: space-between;
  flex-wrap: wrap; gap: 0.5rem;
  font-size: 0.82rem; color: var(--text-muted);
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-soft);
}

.vault-section {
  margin-top: 1.5rem; padding-top: 1.25rem;
  border-top: 1px solid var(--border-soft);
}
.vault-section h4 {
  font-size: 0.82rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.6px;
  font-weight: 600; margin-bottom: 0.75rem;
}

/* ── Badges ── */
.badge {
  display: inline-block; font-size: 0.7rem; font-weight: 600;
  padding: 0.2rem 0.65rem; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-active      { background: rgba(34,197,94,0.12);  color: var(--success);  border: 1px solid rgba(34,197,94,0.25);  }
.badge-paused      { background: rgba(245,158,11,0.12); color: var(--warning);  border: 1px solid rgba(245,158,11,0.25); }
.badge-rebalancing { background: rgba(108,99,255,0.12); color: var(--primary);  border: 1px solid rgba(108,99,255,0.25); }
.badge-unknown     { background: rgba(136,146,164,0.12);color: var(--text-muted);border: 1px solid var(--border); }

/* ── Stats grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.75rem;
}
.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
}
.stat-card.highlight { border-color: rgba(108,99,255,0.4); background: rgba(108,99,255,0.04); }
.stat-label {
  font-size: 0.72rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.3rem;
}
.stat-value { font-size: 1.05rem; font-weight: 600; }

/* ── Asset tabs (for multi-asset deposit) ── */
.asset-tabs {
  display: flex; gap: 0.4rem; margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-soft); padding-bottom: 0.5rem;
}
.asset-tab {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.4rem 0.85rem; border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem;
  transition: all 0.15s;
}
.asset-tab:hover:not(:disabled) { color: var(--text); border-color: var(--text-muted); }
.asset-tab.active {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
}
.asset-tab:disabled { opacity: 0.45; cursor: not-allowed; }
.soon-badge {
  font-size: 0.6rem; padding: 0.05rem 0.35rem;
  background: var(--surface-3); color: var(--text-muted);
  border-radius: 999px; text-transform: uppercase; letter-spacing: 0.5px;
}
.asset-tab.active .soon-badge { background: rgba(255,255,255,0.2); color: #fff; }

/* ── Inputs / hints ── */
.hint {
  font-size: 0.82rem; color: var(--text-muted);
  margin-bottom: 0.6rem; line-height: 1.5;
}
.input-row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.input-row input {
  flex: 1; min-width: 180px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem; font-size: 0.95rem; outline: none;
  transition: border-color 0.15s;
}
.input-row input:focus { border-color: var(--primary); }
.button-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.button-row input {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  padding: 0.5rem 0.8rem; font-size: 0.9rem; min-width: 200px;
}

/* ── Chart ── */
.chart-container {
  position: relative; height: 240px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
}

/* ── Price table ── */
.price-table { font-size: 0.82rem; max-height: 200px; overflow-y: auto; }
.price-table table { width: 100%; border-collapse: collapse; }
.price-table th {
  text-align: left; padding: 0.35rem 0.6rem;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.4px;
  position: sticky; top: 0; background: var(--surface);
}
.price-table td {
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid var(--border-soft);
  font-family: monospace;
}

/* ── Buttons ── */
.btn {
  cursor: pointer; border: none; border-radius: var(--radius-sm);
  padding: 0.6rem 1.1rem; font-size: 0.9rem; font-weight: 600;
  transition: background 0.15s, opacity 0.15s, transform 0.05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled)   { background: var(--primary-h); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-3); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled)    { background: #dc2626; }
.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled)     { color: var(--text); border-color: var(--text-muted); }
.btn-tiny      { padding: 0.3rem 0.7rem; font-size: 0.75rem; }

/* ── Status messages ── */
.status-msg {
  margin-top: 0.6rem; padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm); font-size: 0.85rem;
  white-space: pre-wrap; line-height: 1.45;
}
.status-msg.success { background: rgba(34,197,94,0.08);  color: var(--success); border: 1px solid rgba(34,197,94,0.2); }
.status-msg.error   { background: rgba(239,68,68,0.08);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.2); }
.status-msg.info    { background: rgba(108,99,255,0.08); color: var(--primary); border: 1px solid rgba(108,99,255,0.2); }

/* ── Manager actions ── */
.manager-actions summary {
  cursor: pointer; color: var(--text-muted);
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.6px;
  font-weight: 600; user-select: none;
}
.manager-actions[open] summary { margin-bottom: 0.75rem; }

/* ── Vault placeholder card ── */
.vault-card-placeholder {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
}
.placeholder-title {
  font-size: 0.95rem; font-weight: 600;
  color: var(--text); margin-bottom: 0.75rem;
}
.placeholder-list {
  list-style: none; font-size: 0.85rem;
  display: inline-block; text-align: left;
}
.placeholder-list li { padding: 0.25rem 0; }

/* ── Setup panel ── */
.setup-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.5rem;
}
.setup-panel summary {
  cursor: pointer; color: var(--text-muted);
  font-size: 0.85rem; user-select: none;
}
.setup-panel[open] summary { margin-bottom: 1rem; }

/* ── Footer ── */
footer {
  text-align: center; color: var(--text-muted);
  font-size: 0.78rem; padding-top: 1.5rem; margin-top: 1.5rem;
  border-top: 1px solid var(--border-soft);
}
footer a { color: var(--primary); text-decoration: none; }
footer code { font-size: 0.75rem; }

/* ── Utility ── */
.hidden { display: none !important; }

/* ── Responsive ── */
@media (max-width: 600px) {
  .container { padding: 1rem 0.5rem 3rem; }
  .vault-card-header { padding: 1rem; }
  .vault-card-body { padding: 1rem; }
  .auth-bar { width: 100%; justify-content: flex-start; }
}
/* ── Account: Send (withdraw to wallet) ── */
.account-send {
  margin-top: 0.85rem; padding-top: 0.85rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.85rem; color: var(--text-muted);
}
.account-send summary {
  cursor: pointer; color: var(--primary); user-select: none;
  font-weight: 500;
}
.account-send[open] summary { margin-bottom: 0.85rem; }
.account-send .input-row { margin-bottom: 0.6rem; }
.account-send .hint { color: var(--text-muted); margin: 0.5rem 0 0.85rem; }
.account-send .hint strong { color: var(--text); }
