:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --crypto: #f59e0b;
  --stock: #3b82f6;
  --spv: #8b5cf6;
  --cash: #10b981;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
main { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }

.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}
.topnav .brand { font-weight: 700; font-size: 1.05rem; }
.topnav nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 1.5rem;
  padding: 0.4rem 0;
  border-bottom: 2px solid transparent;
  font-weight: 500;
}
.topnav nav a:hover { color: var(--text); }
.topnav nav a.active { color: var(--primary); border-bottom-color: var(--primary); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.card h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ccy-toggle {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.ccy-toggle .pill {
  padding: 0.3rem 0.95rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.ccy-toggle .pill:hover { color: var(--text); }
.ccy-toggle .pill.active {
  background: var(--primary);
  color: #fff;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat .stat-label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}
.stat .stat-value {
  font-size: 1.7rem;
  font-weight: 700;
  margin-top: 0.4rem;
  letter-spacing: -0.02em;
}
.stat .stat-sub { color: var(--muted); margin-top: 0.15rem; }

.actions-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

table.data {
  width: 100%;
  border-collapse: collapse;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
table.data th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.data tbody tr:hover { background: #f1f5f9; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data code {
  background: #f1f5f9;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.btn {
  display: inline-block;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
}
.btn:hover { background: #f1f5f9; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.small { padding: 0.25rem 0.55rem; font-size: 0.78rem; }

.muted { color: var(--muted); font-size: 0.85rem; }

.kind {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.kind-crypto    { background: #fef3c7; color: #92400e; }
.kind-stock_etf { background: #dbeafe; color: #1e40af; }
.kind-spv       { background: #ede9fe; color: #5b21b6; }
.kind-cash      { background: #d1fae5; color: #065f46; }

.action {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.action-buy        { background: #dcfce7; color: #166534; }
.action-sell       { background: #fee2e2; color: #991b1b; }
.action-deposit    { background: #dbeafe; color: #1e40af; }
.action-withdraw   { background: #fef3c7; color: #92400e; }
.action-reward     { background: #ede9fe; color: #5b21b6; }
.action-swap_in    { background: #cffafe; color: #155e75; }
.action-swap_out   { background: #cffafe; color: #155e75; }

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}
.grid-form label {
  display: flex;
  flex-direction: column;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  gap: 0.25rem;
}
.grid-form input, .grid-form select {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.grid-form input:focus, .grid-form select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
.grid-form .full { grid-column: 1 / -1; }
.grid-form button { align-self: end; }
.grid-form #new-asset-fields {
  display: contents;
}

.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { margin-left: 0.25rem; }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

.inline-edit { background: #f1f5f9; padding: 0.75rem; border-radius: 6px; }
