/* =========================================================
   CoinVault – Modern Dark Investment Dashboard
   ========================================================= */
:root {
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --bg: #0b0f19;
  --bg-elevated: #111827;
  --bg-card: #151c2c;
  --bg-hover: #1c2538;
  --border: #243044;
  --border-strong: #2e3b55;

  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --primary: #6366f1;
  --primary-hover: #818cf8;
  --primary-soft: rgba(99, 102, 241, 0.15);

  --success: #10b981;
  --success-soft: rgba(16, 185, 129, 0.12);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --sidebar-w: 240px;
  --topbar-h: 64px;

  --transition: 0.18s ease;
}

[data-theme="light"] {
  --bg: #f1f5f9;
  --bg-elevated: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --primary-soft: rgba(99, 102, 241, 0.1);
  --success-soft: rgba(16, 185, 129, 0.1);
  --danger-soft: rgba(239, 68, 68, 0.1);
  --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

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

html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; }
ul { list-style: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  pointer-events: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.logo-mark { width: 32px; height: 32px; flex-shrink: 0; }
.logo-mark svg { width: 100%; height: 100%; }

.sidebar-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
}
.nav-item svg { flex-shrink: 0; opacity: 0.9; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  margin-top: auto;
  position: relative;
  z-index: 5;
  pointer-events: auto;
  background: var(--bg-elevated);
}
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text-secondary);
  font-size: 0.9rem;
  width: 100%;
}
.theme-toggle:hover { color: var(--text); }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }
.version { font-size: 0.75rem; color: var(--text-muted); text-align: center; }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

/* ---------- App shell ---------- */
.app {
  margin-left: var(--sidebar-w);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; padding: 8px; border-radius: 8px; color: var(--text-secondary); }
.menu-btn:hover { background: var(--bg-hover); color: var(--text); }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}
.btn-primary:hover { background: linear-gradient(135deg, #818cf8, #6366f1); }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { filter: brightness(1.1); }
.btn-xs {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  border: 1px solid transparent;
}
.btn-xs:hover { border-color: var(--primary); }
.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-secondary);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.link-btn {
  color: var(--primary-hover);
  font-size: 0.85rem;
  font-weight: 500;
}
.link-btn:hover { text-decoration: underline; }

/* ---------- Main ---------- */
.main {
  padding: 24px;
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.section { display: none; animation: fadeIn 0.25s ease; }
.section.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- KPI cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), #22d3ee);
  opacity: 0.7;
}
.kpi-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  line-height: 1.2;
}
.kpi-meta {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
.kpi-value.positive, .kpi-meta.positive { color: var(--success); }
.kpi-value.negative, .kpi-meta.negative { color: var(--danger); }

/* ---------- Panels ---------- */
.panel-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-bottom: 8px;
}
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
}
.chart-wrap {
  position: relative;
  min-height: 220px;
}
.chart-wrap-sm { min-height: 180px; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}
.chart-empty.hidden { display: none; }

.chart-range { display: flex; gap: 6px; }
.chip {
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active {
  background: var(--primary-soft);
  color: var(--primary-hover);
  border-color: transparent;
}

.allocation-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.allocation-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------- Section toolbar ---------- */
.section-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.section-toolbar h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  width: 100%;
  margin-top: -8px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 180px;
}
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  color: var(--text);
  font-size: 0.9rem;
}
.search-box input::placeholder { color: var(--text-muted); }

.select {
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  outline: none;
}
.select:focus { border-color: var(--primary); }

/* ---------- Holdings cards ---------- */
.holdings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.coin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.coin-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.coin-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.coin-logo {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--bg-hover);
  object-fit: cover;
  flex-shrink: 0;
}
.coin-info { flex: 1; min-width: 0; }
.coin-name {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.coin-symbol {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-hover);
  padding: 2px 7px;
  border-radius: 6px;
  text-transform: uppercase;
}
.coin-price {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.coin-change {
  font-size: 0.8rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}
.coin-change.up { background: var(--success-soft); color: var(--success); }
.coin-change.down { background: var(--danger-soft); color: var(--danger); }

.coin-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}
.stat-value {
  font-weight: 600;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  word-break: break-all;
}
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

.coin-pnl-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--bg-hover);
  overflow: hidden;
}
.coin-pnl-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.coin-pnl-fill.pos { background: var(--success); }
.coin-pnl-fill.neg { background: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  font-size: 0.88rem;
}
.data-table .actions { text-align: right; width: 100px; }
.asset-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.asset-cell img {
  width: 28px; height: 28px;
  border-radius: 50%;
}
.row-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}
.row-actions button {
  padding: 6px;
  border-radius: 6px;
  color: var(--text-muted);
}
.row-actions button:hover { background: var(--bg); color: var(--text); }
.row-actions .del:hover { color: var(--danger); }

.positive { color: var(--success) !important; }
.negative { color: var(--danger) !important; }

/* ---------- Empty states ---------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 6px;
}
.empty-state p { margin-bottom: 18px; font-size: 0.95rem; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.15s ease;
}
.modal-backdrop[hidden] { display: none !important; }
.modal-backdrop.is-open {
  display: flex !important;
}
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  width: 100%;
  max-width: 480px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.2s ease;
}
.modal-sm { max-width: 380px; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.modal-body { padding: 20px; }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}
.optional { font-weight: 400; color: var(--text-muted); }
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition);
}
.form-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.input-with-action {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.input-with-action input { flex: 1; }
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  padding-top: 8px;
}

/* Coin search */
.coin-search-wrap { position: relative; }
.coin-selected {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.coin-selected img { border-radius: 50%; }
.coin-selected span { flex: 1; font-weight: 600; }
.coin-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: var(--shadow);
}
.coin-dropdown li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background var(--transition);
}
.coin-dropdown li:hover { background: var(--bg-hover); }
.coin-dropdown img { width: 24px; height: 24px; border-radius: 50%; }
.coin-dropdown .sym {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* ---------- Toasts ---------- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  padding: 12px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.25s ease;
  max-width: 340px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--primary); }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Loading / skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border) 50%, var(--bg-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-row { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .app { margin-left: 0; }
  .menu-btn { display: grid; place-items: center; }
  .hide-sm { display: none; }
  .main { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 1.25rem; }
  .form-row { grid-template-columns: 1fr; }
  .topbar { padding: 0 12px; }
  .holdings-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ---------- Auth / Login ---------- */
.login-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}
.login-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99, 102, 241, 0.25), transparent),
    radial-gradient(ellipse 70% 50% at 90% 80%, rgba(34, 211, 238, 0.12), transparent),
    var(--bg);
  z-index: 0;
}
.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 6px);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .logo-mark {
  width: 48px;
  height: 48px;
  margin: 0 auto 14px;
}
.login-brand h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}
.login-brand p {
  color: var(--text-muted);
  font-size: 0.9rem;
}
.login-alert {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 18px;
}
.login-form .btn-block {
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
}
.login-hint {
  margin-top: 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrap input {
  width: 100%;
  padding-right: 44px;
}
.pw-toggle {
  position: absolute;
  right: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.95rem;
  opacity: 0.7;
}
.pw-toggle:hover { opacity: 1; background: var(--bg-hover); }

.form-group input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition);
}
.form-group input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  margin-bottom: 4px;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #22d3ee);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.user-name {
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.btn-sidebar {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn-sidebar:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-sidebar:active {
  transform: scale(0.98);
}
.btn-sidebar-danger:hover {
  color: var(--danger);
  background: var(--danger-soft);
}
a.btn-sidebar {
  text-decoration: none;
}


/* Dual currency on Total Value */
.kpi-value-vnd {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  letter-spacing: -0.02em;
  margin-top: 4px;
  line-height: 1.3;
}
.kpi-fx {
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.kpi-card-value .kpi-meta {
  margin-top: 4px;
}


/* Dual USD + VND money display */
.money-dual {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.25;
}
.money-dual-inline {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px;
}
.money-usd {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.money-vnd {
  font-size: 0.78em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
  color: var(--text-secondary);
  opacity: 0.95;
}
.money-sep {
  color: var(--text-muted);
  font-size: 0.75em;
}
.kpi-value .money-dual {
  gap: 4px;
}
.kpi-value .money-usd {
  font-size: 1em;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.kpi-value .money-vnd {
  font-size: 0.68em;
  font-weight: 700;
  color: var(--text-secondary);
}
.kpi-value.positive .money-vnd,
.kpi-value.negative .money-vnd {
  opacity: 0.85;
}
.stat-value .money-dual {
  gap: 2px;
}
.stat-value .money-usd {
  font-size: 0.95rem;
}
.stat-value .money-vnd {
  font-size: 0.75rem;
}
.data-table .money-dual {
  align-items: flex-end;
  text-align: right;
}
.data-table .money-usd {
  font-size: 0.88rem;
}
.data-table .money-vnd {
  font-size: 0.72rem;
}
.coin-price {
  line-height: 1.45;
}


/* Coin card click + detail modal */
.coin-card {
  cursor: pointer;
}
.coin-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.coin-card-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2px;
  opacity: 0.8;
}
.modal-lg {
  max-width: 820px;
}
.coin-detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.coin-detail-head img {
  border-radius: 50%;
  flex-shrink: 0;
}
.coin-detail-head h2 {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.2;
}
.coin-detail-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.coin-detail-body {
  padding-top: 12px;
}
.coin-detail-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.coin-detail-summary .stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
@media (max-width: 700px) {
  .coin-detail-summary {
    grid-template-columns: 1fr 1fr;
  }
  .modal-lg {
    max-width: 100%;
  }
}


/* XL split modal: chart | buy-ins */
.modal-xl {
  max-width: min(1280px, calc(100vw - 24px));
  width: 100%;
  height: min(88dvh, 900px);
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-xl .modal-header {
  flex-shrink: 0;
}
.coin-detail-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
  padding: 0 !important;
  overflow: hidden;
}
.coin-detail-chart-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
}
.coin-detail-chart-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.tv-symbol {
  font-family: var(--mono);
  text-transform: none;
  letter-spacing: 0;
  color: var(--primary-hover);
  font-weight: 600;
}
.coin-detail-tv {
  flex: 1;
  min-height: 420px;
  position: relative;
  overflow: hidden;
}
.coin-detail-tv .tradingview-widget-container,
.coin-detail-tv .tradingview-widget-container__widget {
  height: 100% !important;
  width: 100% !important;
}
.coin-detail-tv iframe {
  height: 100% !important;
  width: 100% !important;
}
.coin-detail-data-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 14px 16px 16px;
  background: var(--bg-elevated);
}
.coin-detail-data-pane .coin-detail-summary {
  flex-shrink: 0;
}
.coin-detail-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  max-height: none;
}
.coin-detail-tv-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 24px;
  text-align: center;
}

@media (max-width: 960px) {
  .modal-xl {
    height: min(94dvh, 100%);
    max-height: 96dvh;
  }
  .coin-detail-split {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(280px, 42%) 1fr;
    overflow-y: auto;
  }
  .coin-detail-chart-pane {
    border-right: none;
    border-bottom: 1px solid var(--border);
    min-height: 280px;
  }
  .coin-detail-tv {
    min-height: 260px;
  }
  .coin-detail-data-pane {
    overflow: auto;
  }
}


/* Analytics */
.analytics-kpi .kpi-value {
  font-size: 1.45rem;
}
.analytics-row {
  margin-bottom: 16px;
}
.analytics-insights-panel {
  margin-bottom: 8px;
}
.insights-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.insights-list li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  line-height: 1.45;
  color: var(--text-secondary);
}
.insights-list .insight-icon {
  flex-shrink: 0;
  font-size: 1.1rem;
  line-height: 1.3;
}
.insights-list .insight-text strong {
  color: var(--text);
  font-weight: 600;
}
.insight-warn {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.08);
}
.insight-good {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}
.insight-bad {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}
.insight-info {
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.08);
}
