/* AVA Portfolio — dark fintech theme */
:root {
  --bg: #0a0d13;
  --bg-elev: #10141c;
  --bg-elev-2: #151a24;
  --bg-hover: #1a2030;
  --border: #1d2330;
  --border-strong: #2a3242;
  --text: #e7eaf0;
  --text-dim: #8d97a8;
  --text-faint: #5a6476;
  --accent: #7b8cff;
  --accent-2: #b07cff;
  --accent-soft: rgba(123, 140, 255, 0.12);
  --up: #2ebd85;
  --up-soft: rgba(46, 189, 133, 0.12);
  --down: #f6465d;
  --down-soft: rgba(246, 70, 93, 0.12);
  --warn: #f0b90b;
  --warn-soft: rgba(240, 185, 11, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  background-image: radial-gradient(1200px 500px at 10% -10%, rgba(123, 140, 255, 0.07), transparent 60%),
                    radial-gradient(900px 400px at 100% 0%, rgba(176, 124, 255, 0.05), transparent 60%);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
  min-height: 100vh;
}
.num, td, .kpi-value, .hero-value { font-variant-numeric: tabular-nums; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }
.up { color: var(--up); }
.down { color: var(--down); }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 24px;
  background: rgba(10, 13, 19, 0.82);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: 0.2px; font-size: 15px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 4px 16px rgba(123, 140, 255, 0.35);
}
.brand-mark svg { width: 16px; height: 16px; }
.brand small { color: var(--text-dim); font-weight: 500; }
.status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--bg-elev);
  font-size: 12px; color: var(--text-dim); white-space: nowrap;
}
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }
.status.live .dot { background: var(--up); box-shadow: 0 0 0 3px var(--up-soft); animation: pulse 2s infinite; }
.status.stale .dot { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.status.offline .dot { background: var(--down); box-shadow: 0 0 0 3px var(--down-soft); }
.status.live { color: var(--text); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
.topbar .spacer { flex: 1; }
.actions { display: flex; gap: 8px; align-items: center; position: relative; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-elev-2);
  cursor: pointer; font-weight: 550; font-size: 13px; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: var(--bg-hover); border-color: #36405a; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .seg button:focus-visible, .tabs button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn.primary { background: linear-gradient(135deg, #6f80ff, #8e6dff); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.buy { background: var(--up); border-color: transparent; color: #04120c; }
.btn.sell { background: var(--down); border-color: transparent; color: #fff; }
.btn.danger { background: var(--down-soft); border-color: rgba(246, 70, 93, 0.35); color: #ff8595; }
.btn.danger:hover { background: rgba(246, 70, 93, 0.2); }
.btn.ghost { background: transparent; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.block { width: 100%; height: 40px; }
.icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center;
  border-radius: 7px; border: 1px solid transparent; background: transparent;
  color: var(--text-dim); cursor: pointer;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border); }
.icon-btn.danger:hover { color: var(--down); }
.icon-btn svg { width: 15px; height: 15px; }

.menu {
  position: absolute; right: 0; top: 42px; min-width: 190px; padding: 6px;
  background: var(--bg-elev-2); border: 1px solid var(--border-strong);
  border-radius: 10px; box-shadow: var(--shadow); z-index: 30;
}
.menu button {
  display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px;
  border: 0; background: transparent; border-radius: 6px; cursor: pointer; text-align: left;
}
.menu button:hover { background: var(--bg-hover); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* ---------------------------------------------------------------- layout */
.container { max-width: 1320px; margin: 0 auto; padding: 24px; display: grid; gap: 20px; }
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.012), transparent 40%), var(--bg-elev);
  border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 0;
}
.panel-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; color: var(--text-dim); }
.panel-head .spacer { flex: 1; }
.panel-head .count { color: var(--text-faint); font-weight: 500; }

.banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid rgba(240, 185, 11, 0.35); background: var(--warn-soft); color: #f6d36b; font-size: 13px;
}
.banner.error { border-color: rgba(246, 70, 93, 0.35); background: var(--down-soft); color: #ff9aa7; }

/* ------------------------------------------------------------------ hero */
.hero { display: grid; grid-template-columns: minmax(280px, 1.1fr) 2.4fr; gap: 20px; }
.hero-main { padding: 22px 24px; display: flex; flex-direction: column; justify-content: center; gap: 6px; position: relative; overflow: hidden; }
.hero-main::after {
  content: ""; position: absolute; inset: auto -40px -60px auto; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(123, 140, 255, 0.16), transparent 70%); pointer-events: none;
}
.label { color: var(--text-dim); font-size: 12px; font-weight: 550; letter-spacing: 0.3px; text-transform: uppercase; }
.hero-value { font-size: 38px; font-weight: 680; letter-spacing: -1px; line-height: 1.1; }
.hero-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--bg-hover); color: var(--text-dim);
}
.pill.up { background: var(--up-soft); color: var(--up); }
.pill.down { background: var(--down-soft); color: var(--down); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.kpi { background: var(--bg-elev); padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-value { font-size: 21px; font-weight: 640; letter-spacing: -0.4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-foot { font-size: 12px; color: var(--text-faint); }

.alloc { padding: 14px 18px; display: grid; gap: 10px; }
.alloc-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: var(--bg-hover); gap: 2px; }
.alloc-bar span { display: block; height: 100%; min-width: 3px; }
.alloc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--text-dim); }
.alloc-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: right; font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--text-faint); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { text-align: right; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; padding-left: 18px; }
th:last-child, td:last-child { padding-right: 18px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 0.12s; }
.holdings tbody tr { cursor: pointer; }
.holdings tbody tr:hover, .history tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
.holdings tbody tr.selected { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.holdings tbody tr.closed td { color: var(--text-dim); }
td .sub { display: block; font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.asset-cell { display: flex; align-items: center; gap: 10px; }
.coin {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-size: 11px; font-weight: 700; color: #fff; letter-spacing: -0.2px;
}
.coin.lg { width: 38px; height: 38px; font-size: 13px; }
.asset-name { font-weight: 620; }
.tag {
  display: inline-block; padding: 1px 6px; border-radius: 4px; font-size: 10.5px; font-weight: 650;
  letter-spacing: 0.4px; text-transform: uppercase; vertical-align: 1px;
  background: var(--bg-hover); color: var(--text-dim); border: 1px solid var(--border-strong);
}
.tag.buy { background: var(--up-soft); color: var(--up); border-color: rgba(46,189,133,.25); }
.tag.sell { background: var(--down-soft); color: var(--down); border-color: rgba(246,70,93,.25); }
.tag.opening { background: var(--accent-soft); color: var(--accent); border-color: rgba(123,140,255,.3); }
.tag.stale { background: var(--warn-soft); color: var(--warn); border-color: rgba(240,185,11,.3); margin-left: 6px; }
.price-stale { color: var(--text-dim); text-decoration: underline dotted var(--warn); text-underline-offset: 3px; }
.mini-bar { display: inline-block; width: 46px; height: 4px; border-radius: 99px; background: var(--bg-hover); vertical-align: middle; margin-left: 8px; overflow: hidden; }
.mini-bar b { display: block; height: 100%; background: var(--accent); }
.row-actions { display: inline-flex; gap: 2px; }
.note { display: block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* ---------------------------------------------------------- chart/detail */
.split { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, 1fr); gap: 20px; }
.chart-head { display: flex; align-items: center; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chart-title { display: flex; align-items: center; gap: 12px; }
.chart-title .big { font-size: 20px; font-weight: 660; letter-spacing: -0.3px; }
.tabs, .seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--bg); border: 1px solid var(--border); gap: 2px; }
.tabs button, .seg button {
  border: 0; background: transparent; padding: 5px 10px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--text-dim);
}
.tabs button.active, .seg button.active { background: var(--bg-hover); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset; }
.seg { width: 100%; }
.seg button { flex: 1; padding: 8px; font-size: 13px; }
.seg button.active.buy { background: var(--up-soft); color: var(--up); }
.seg button.active.sell { background: var(--down-soft); color: var(--down); }
.seg button.active.opening { background: var(--accent-soft); color: var(--accent); }
.chart-box { position: relative; height: 340px; padding: 8px 6px 4px; }
.chart-box #chart { position: absolute; inset: 8px 6px 4px; }
.chart-overlay {
  position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-faint); font-size: 13px;
  pointer-events: none; text-align: center; padding: 20px;
}
.chart-legend { display: flex; gap: 16px; padding: 0 18px 14px; font-size: 12px; color: var(--text-dim); flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--accent); vertical-align: middle; margin-right: 6px; }
.chart-legend i.entry { border-top: 2px dashed var(--warn); }

.detail { display: flex; flex-direction: column; }
.detail-body { padding: 6px 18px 18px; display: grid; gap: 0; }
.stat-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.stat-row:last-child { border-bottom: 0; }
.stat-row span:first-child { color: var(--text-dim); }
.stat-row span:last-child { font-weight: 560; text-align: right; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 18px 18px; margin-top: auto; }
.detail-actions .full { grid-column: 1 / -1; }

/* ---------------------------------------------------------------- states */
.empty { padding: 48px 20px; text-align: center; color: var(--text-dim); display: grid; gap: 12px; justify-items: center; }
.empty h3 { margin: 0; color: var(--text); font-size: 16px; }
.empty p { margin: 0; max-width: 380px; }
.skeleton { display: inline-block; height: 1em; width: 120px; border-radius: 6px; vertical-align: middle;
  background: linear-gradient(90deg, var(--bg-hover) 0%, #222a3a 50%, var(--bg-hover) 100%); background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear; }
.skeleton.w-s { width: 70px; } .skeleton.w-l { width: 200px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.select {
  height: 30px; padding: 0 28px 0 10px; border-radius: 7px; border: 1px solid var(--border-strong);
  background: var(--bg-elev-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238d97a8' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none; -webkit-appearance: none; font-size: 12px; cursor: pointer;
}
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--accent); }

/* ---------------------------------------------------------------- dialog */
dialog {
  width: min(460px, calc(100vw - 24px)); padding: 0; border: 1px solid var(--border-strong);
  border-radius: 14px; background: var(--bg-elev); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(4, 6, 10, 0.7); backdrop-filter: blur(3px); }
dialog[open] { animation: pop 0.16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 640; }
.modal-body { padding: 18px 20px; display: grid; gap: 14px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal-foot .spacer { flex: 1; }
.field { display: grid; gap: 6px; }
.field > label, .field > .flabel { font-size: 12px; font-weight: 600; color: var(--text-dim); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field > label .hint { font-weight: 500; color: var(--text-faint); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .prefix { position: absolute; left: 11px; color: var(--text-faint); pointer-events: none; }
.input-wrap .suffix-btn { position: absolute; right: 5px; }
.input {
  width: 100%; height: 38px; padding: 0 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s; font-variant-numeric: tabular-nums;
}
.input.has-prefix { padding-left: 24px; }
.input.has-suffix { padding-right: 58px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input[aria-invalid="true"] { border-color: var(--down); }
textarea.input { height: 64px; padding: 9px 11px; resize: vertical; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 12px; font-weight: 600; }
.chip-btn { height: 26px; padding: 0 8px; font-size: 11px; font-weight: 650; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--bg-hover); cursor: pointer; color: var(--text-dim); }
.chip-btn:hover { color: var(--text); }
.form-error { padding: 9px 12px; border-radius: 8px; background: var(--down-soft); color: #ff9aa7; font-size: 13px; border: 1px solid rgba(246,70,93,.3); }
.preview { padding: 11px 13px; border-radius: 9px; background: var(--bg); border: 1px solid var(--border); font-size: 12.5px; display: grid; gap: 4px; }
.preview div { display: flex; justify-content: space-between; gap: 10px; }
.preview span:first-child { color: var(--text-dim); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; }
.confirm-text { margin: 0; color: var(--text-dim); }
.confirm-text strong { color: var(--text); }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 100; max-width: calc(100vw - 36px); }
.toast {
  padding: 11px 14px; border-radius: 10px; background: var(--bg-elev-2); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow); font-size: 13px; display: flex; gap: 10px; align-items: center; animation: pop 0.18s ease-out;
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--up); flex: none; }
.toast.error::before { background: var(--down); }

.footer { text-align: center; color: var(--text-faint); font-size: 12px; padding: 8px 0 28px; }
.footer a { color: var(--text-dim); text-decoration: none; }
.footer a:hover { color: var(--text); }

/* ----------------------------------------------------------------- login */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: min(380px, 100%); padding: 32px 28px; display: grid; gap: 18px; }
.login-card .brand { justify-content: center; font-size: 18px; }
.login-card .brand-mark { width: 36px; height: 36px; border-radius: 10px; }
.login-card .brand-mark svg { width: 20px; height: 20px; }
.login-card p { margin: 0; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; gap: 10px; }
  .brand small, .actions .btn .lbl { display: none; }
  .status .status-detail { display: none; }
  .container { padding: 14px; gap: 14px; }
  .hero-value { font-size: 32px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 17px; }
  .chart-box { height: 260px; }
  .row2 { grid-template-columns: 1fr; }
  /* tables -> cards */
  .cards thead { display: none; }
  .cards tbody, .cards tr, .cards td { display: block; }
  .cards tr { padding: 14px 16px; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
  .cards tbody tr:last-child { border-bottom: 0; }
  .cards td { border: 0; padding: 0; text-align: left; white-space: normal; min-width: 0; }
  .cards td::before { content: attr(data-label); display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text-faint); margin-bottom: 1px; }
  .cards td.primary { grid-column: 1 / -1; text-align: left; padding-bottom: 6px; }
  .cards td .mini-bar { margin-left: 6px; }
  .panel-head { padding: 12px 16px; }
  .cards td.primary::before { display: none; }
  .cards td.actions-cell { grid-column: 1 / -1; text-align: right; margin-top: -4px; }
  .cards td.actions-cell::before { display: none; }
  .cards td:first-child, .cards td:last-child { padding: 0; }
  .holdings tbody tr.selected { box-shadow: inset 3px 0 0 var(--accent); }
}
