/* Asset Dashboard theme — palette lifted from the Claude Design mockup. */

:root {
  --bg: #0b0c0e;
  --card: #13161c;
  --panel: #1c1f26;
  --panel-2: #23262e;
  --panel-3: #1e2128;

  /* Lifted alongside the surfaces so edges stay legible against them. */
  --border: #2b2f39;
  --border-2: #363b47;

  --text: #eceef2;
  --text-1: #dfe3ea;
  --text-2: #cbd0d9;
  --text-3: #9aa0ac;

  --muted: #757b88;
  --muted-2: #6b7180;
  --muted-3: #676d79;
  --muted-4: #565c68;

  --pos: #8fb08a;
  --neg: #c88b7d;
  --line: #8ba0c0;

  --accent-a: #3d8bff;
  --accent-b: #16c79a;

  /* Liquidity split reuses the two accent hues. */
  --liquid: #16c79a;
  --illiquid: #3d8bff;

  --radius: 14px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

/* Always reserve the scrollbar gutter. Without it, short pages (/admin) have no
   scrollbar while long ones (/edit) do, so the layout shifts sideways by the
   scrollbar width as you move between pages. */
html {
  scrollbar-gutter: stable;
}

@supports not (scrollbar-gutter: stable) {
  html {
    overflow-y: scroll;
  }
}

/* Dark scrollbars and native controls, now that a scrollbar is always present. */
:root {
  color-scheme: dark;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: #e6e8ec;
  font-family: 'Geist', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: #8aa0bd;
  text-decoration: none;
}

a:hover {
  color: #a9bcd6;
}

.mono {
  font-family: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-feature-settings: 'tnum' 1;
}

:focus-visible {
  outline: 2px solid var(--line);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ layout */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* --------------------------------------------------------------------- nav */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.nav-logo {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  display: block;
  flex-shrink: 0;
}

.nav-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-link {
  padding: 6px 11px;
  font-size: 13px;
  color: var(--muted-2);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.nav-link:hover {
  color: var(--text-2);
  background: var(--panel-3);
}

.nav-link.active {
  color: var(--text-1);
  background: #23272f;
  border-color: var(--border-2);
}

/* ----------------------------------------------------------------- buttons */

.btn {
  font: inherit;
  font-size: 13px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--panel-3);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.btn:hover {
  background: #23272f;
  color: var(--text);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  border-color: transparent;
  color: #0b0c0e;
  font-weight: 600;
}

/* The gradient must be restated here: .btn:hover sets a flat background at the
   same specificity, which would otherwise replace it with dark grey. */
.btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-a), var(--accent-b));
  filter: brightness(1.08);
  color: #0b0c0e;
}

.btn-danger {
  color: var(--neg);
  border-color: #3a2a2a;
}

.btn-danger:hover {
  background: #2a1e1e;
  color: var(--neg);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted-2);
  padding: 4px 8px;
}

.btn-ghost:hover {
  background: var(--panel-2);
  color: var(--text-2);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Segmented 1M / 6M / 12M control. */
.segmented {
  display: inline-flex;
  background: var(--panel-3);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segmented button {
  font: inherit;
  font-size: 12px;
  padding: 5px 11px;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
}

.segmented button.active {
  color: var(--text-1);
  background: #23272f;
}

/* ------------------------------------------------------------------- forms */

label {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}

input[type='text'],
input[type='password'],
input[type='number'],
select {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 9px 11px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--line);
  outline: none;
}

/* No spinner arrows — amounts are typed, and a stray scroll over a focused
   field must never nudge a monetary value. */
input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type='color'] {
  width: 34px;
  height: 34px;
  padding: 2px;
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.field {
  margin-bottom: 14px;
}

.error-text {
  color: var(--neg);
  font-size: 13px;
  min-height: 18px;
  margin-top: 8px;
}

.hint {
  font-size: 11.5px;
  color: var(--muted-3);
  margin-top: 6px;
}

/* ------------------------------------------------------- dialog and toast */

dialog {
  background: var(--card);
  border: 1px solid var(--border-2);
  border-radius: 12px;
  color: var(--text);
  padding: 20px;
  max-width: 380px;
  width: calc(100% - 40px);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

dialog h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--panel);
  border: 1px solid var(--border-2);
  color: var(--text-1);
  font-size: 13px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* ---------------------------------------------------------- dashboard card */

.dash-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

/* Only the range toggle lives here now, so it sits to the right on its own. */
.dash-head {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}

.panel-label {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.kpi-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-value {
  font-size: 34px;
  font-weight: 600;
  line-height: 1;
  margin-top: 8px;
  letter-spacing: -0.5px;
}

.kpi-change {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  font-size: 12.5px;
}

.kpi-change .pct {
  color: var(--muted-2);
}

.kpi-boxes {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.kpi-box {
  flex: 1;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.kpi-box-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
}

.kpi-box-value {
  font-size: 14px;
  color: var(--text-2);
  margin-top: 3px;
}

.kpi-box-value.debt {
  color: var(--neg);
}

/* Trend panel */

.trend-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 16px 10px;
  display: flex;
  flex-direction: column;
}

.trend-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.trend-svg {
  width: 100%;
  height: 118px;
  display: block;
  margin-top: 8px;
}

.trend-months {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 10px;
  color: var(--muted-4);
}

/* Category cards */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.cat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 14px 15px;
  position: relative;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, transform 0.14s ease;
}

.cat-card:hover {
  background: var(--panel-2);
  border-color: var(--border-2);
}

.cat-card:active {
  transform: translateY(1px);
}

.cat-card.expanded {
  background: var(--panel-2);
  border-color: var(--line);
}

/* Count badge when a category holds more than one line item. */
.cat-count {
  font-size: 10px;
  color: var(--muted-2);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  padding: 1px 5px;
  flex-shrink: 0;
}

/* Chevron hints that the card opens; it points down, and up once expanded.
   It lives in the header rather than the corner so it never overlaps the
   sparkline's latest point. */
.cat-chevron {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  margin-left: 1px;
  margin-bottom: 3px;
  border-right: 1.5px solid var(--muted-4);
  border-bottom: 1.5px solid var(--muted-4);
  transform: rotate(45deg);
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.cat-card:hover .cat-chevron {
  border-color: var(--text-3);
}

.cat-card.expanded .cat-chevron {
  transform: rotate(-135deg);
  border-color: var(--line);
}

/* ------------------------------------------------------- category drawer */

/* Decelerating curve: fast to start, settling gently, which reads as smoother
   than a symmetric ease at the same duration. */
.cat-drawer {
  grid-column: 1 / -1;
  overflow: hidden;
  height: 0;
  transition: height 0.34s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.cat-drawer.closing {
  transition: height 0.28s cubic-bezier(0.55, 0, 0.68, 0.53);
}

.drawer-inner {
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: 11px;
  padding: 14px 16px 6px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.26s ease-out, transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Contents drift in behind the height change and fade back out on the way down. */
.cat-drawer.opening .drawer-inner,
.cat-drawer.closing .drawer-inner {
  opacity: 0;
  transform: translateY(-8px);
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.drawer-count {
  font-size: 11px;
  color: var(--muted-3);
  flex: 1;
}

.drawer-row {
  display: grid;
  grid-template-columns: 1fr 90px 64px 110px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.drawer-row:last-child {
  border-bottom: 0;
}

.drawer-label {
  font-size: 13px;
  color: var(--text-2);
}

.drawer-sub {
  font-size: 10.5px;
  color: var(--muted-3);
  margin-top: 2px;
}

.drawer-spark {
  width: 90px;
  height: 24px;
  display: block;
}

.drawer-perf {
  font-size: 11.5px;
  text-align: right;
}

.drawer-value {
  font-size: 14px;
  color: var(--text);
  text-align: right;
}

.drawer-empty {
  font-size: 12.5px;
  color: var(--muted-3);
  padding: 12px 0 16px;
}

@media (max-width: 680px) {
  .drawer-row {
    grid-template-columns: 1fr auto;
    row-gap: 4px;
  }

  .drawer-spark {
    display: none;
  }

  .drawer-perf {
    text-align: left;
  }
}

.cat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cat-name-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: block;
  flex-shrink: 0;
}

.cat-name {
  font-size: 13px;
  color: var(--text-2);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-size: 11.5px;
  padding: 2px 7px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
}

.cat-value {
  font-size: 20px;
  color: var(--text);
  margin-top: 11px;
  letter-spacing: -0.3px;
}

.cat-meta {
  font-size: 10.5px;
  color: var(--muted-3);
  margin-top: 2px;
}

.spark {
  width: 100%;
  height: 34px;
  margin-top: 10px;
  display: block;
}

/* Allocation donut */

.alloc-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 14px 15px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.alloc-donut {
  width: 92px;
  height: 92px;
  flex-shrink: 0;
}

.alloc-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.alloc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.alloc-row .name {
  color: var(--text-3);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alloc-row .pct {
  color: #b9bec8;
}

/* Liquid vs illiquid */

.liq-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 14px 15px;
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.liq-bar {
  display: flex;
  height: 12px;
  border-radius: 6px;
  overflow: hidden;
  margin: 11px 0 13px;
  background: var(--panel-2);
}

.liq-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  flex-wrap: wrap;
}

.liq-legend > div {
  display: flex;
  align-items: center;
  gap: 7px;
}

.liq-swatch {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

.liq-legend .label {
  color: var(--text-3);
}

.liq-legend .value {
  color: var(--text-1);
}

.liq-legend .pct {
  color: var(--muted-3);
}

/* Banner shown when an admin is viewing someone else's data */

.banner {
  background: var(--panel-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: 12.5px;
  color: var(--text-3);
  margin-bottom: 14px;
}

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--muted-2);
  font-size: 14px;
}

.empty p {
  margin: 0 0 16px;
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 820px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .cat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dash-card {
    padding: 18px 16px 20px;
  }
}

@media (max-width: 560px) {
  .page {
    padding: 18px 12px 48px;
  }

  .cat-grid {
    grid-template-columns: 1fr;
  }

  .liq-card {
    grid-column: span 1;
  }

  .kpi-value {
    font-size: 28px;
  }

  .liq-legend {
    flex-direction: column;
    gap: 8px;
  }
}
