/* ==========================================================================
   PingBlox — design tokens
   ========================================================================== */
:root {
  color-scheme: dark;

  --bg: #070708;
  --surface: #0d0d0f;
  --surface-2: #121215;
  --surface-3: #18181c;
  --hover: rgba(255, 255, 255, 0.025);

  --line: rgba(255, 255, 255, 0.06);
  --line-2: rgba(255, 255, 255, 0.1);
  --line-3: rgba(255, 255, 255, 0.16);

  --text: #ededef;
  --text-2: #9d9da6;
  --text-3: #61616a;

  --green: #5fd4a0;
  --green-bg: rgba(95, 212, 160, 0.1);
  --amber: #e9b45a;
  --amber-bg: rgba(233, 180, 90, 0.1);
  --red: #ec6a6a;
  --red-bg: rgba(236, 106, 106, 0.1);
  --gold: #d9bf8c;
  --gold-bg: rgba(217, 191, 140, 0.1);

  --radius-sm: 7px;
  --radius: 11px;
  --radius-lg: 16px;

  --font: 'Geist', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 140ms;
  --base: 220ms;

  --gutter: clamp(16px, 3vw, 32px);
  --max: 1320px;
}

/* ==========================================================================
   Base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 520px at 50% -260px, rgba(255, 255, 255, 0.045), transparent 70%),
    var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  font-feature-settings: 'ss01', 'cv11';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
code { font-family: var(--mono); font-size: 0.92em; color: var(--text-2); }
::selection { background: rgba(255, 255, 255, 0.18); }

:focus-visible { outline: 2px solid rgba(255, 255, 255, 0.5); outline-offset: 2px; }

.sprite { position: absolute; }

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }

/* ==========================================================================
   Layout
   ========================================================================== */
.app { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter) 64px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 64px;
  margin: 0 calc(var(--gutter) * -1);
  padding: 0 var(--gutter);
  background: rgba(7, 7, 8, 0.72);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; margin-right: auto; font-weight: 600; letter-spacing: -0.02em; font-size: 15px; }

.topbar-actions { display: flex; gap: 8px; }

.main { display: grid; gap: 28px; padding-top: 32px; }

/* ==========================================================================
   Buttons & inputs
   ========================================================================== */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  transition: background var(--fast), border-color var(--fast), color var(--fast), transform var(--fast) var(--ease), opacity var(--fast);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; pointer-events: none; }

.btn-primary { background: var(--text); color: #0a0a0b; }
.btn-primary:hover { background: #fff; }

.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-3); }

.btn-danger { background: var(--red); color: #140606; }
.btn-danger:hover { background: #f27d7d; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-2);
  transition: background var(--fast), color var(--fast), border-color var(--fast);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--line); }
.icon-btn.is-danger:hover { color: var(--red); background: var(--red-bg); border-color: transparent; }

.is-busy .icon-refresh,
.btn.is-busy .icon,
.icon-btn.is-busy .icon { animation: spin 0.8s linear infinite; }
.is-busy { pointer-events: none; }

.spinner {
  display: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.6px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.7s linear infinite;
}
.is-loading .spinner { display: inline-block; }
.is-loading { pointer-events: none; opacity: 0.85; }

.search,
.select {
  position: relative;
  display: flex;
  align-items: center;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  transition: border-color var(--fast), background var(--fast);
}
.search:focus-within,
.select:focus-within { border-color: var(--line-3); background: var(--surface-2); }

.search .icon { position: absolute; left: 11px; color: var(--text-3); pointer-events: none; }
.search input {
  width: 220px;
  height: 100%;
  padding: 0 12px 0 34px;
  border: 0;
  background: none;
  outline: none;
  font-size: 13.5px;
}
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { display: none; }

.select select {
  appearance: none;
  height: 100%;
  padding: 0 34px 0 12px;
  border: 0;
  background: none;
  outline: none;
  font-size: 13.5px;
  cursor: pointer;
}
.select select option { background: var(--surface-2); }
.select .icon { position: absolute; right: 10px; color: var(--text-3); pointer-events: none; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ==========================================================================
   Overview
   ========================================================================== */
.overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }

.stat {
  position: relative;
  display: grid;
  gap: 14px;
  padding: 18px 20px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  overflow: hidden;
  animation: rise 0.5s var(--ease) both;
}
.stat:nth-child(2) { animation-delay: 40ms; }
.stat:nth-child(3) { animation-delay: 80ms; }
.stat:nth-child(4) { animation-delay: 120ms; }
.stat:nth-child(5) { animation-delay: 160ms; }
.stat:nth-child(6) { animation-delay: 200ms; }
.stat:nth-child(7) { animation-delay: 240ms; }
.stat::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.12), transparent);
}

.stat-head { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.stat-head .icon { color: var(--text-3); width: 15px; height: 15px; }

.stat-value { display: flex; align-items: center; gap: 10px; font-size: 28px; font-weight: 500; line-height: 1.1; letter-spacing: -0.03em; }
.stat-value .icon { width: 20px; height: 20px; stroke-width: 1.8; }
.stat-value.is-green .icon { color: var(--green); }
.stat-value.is-amber .icon { color: var(--amber); }
.stat-value.is-gold .icon { color: var(--gold); }

.stat.is-total {
  background: linear-gradient(180deg, var(--gold-bg), var(--surface));
  border-color: rgba(217, 191, 140, 0.3);
}
.stat.is-total .stat-value { font-size: 32px; }

.stat-foot { color: var(--text-3); font-size: 12.5px; }
.stat-foot strong { color: var(--text-2); font-weight: 500; }

/* ==========================================================================
   Accounts panel
   ========================================================================== */
.panel {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  animation: rise 0.5s var(--ease) 0.12s both;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-title { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }
.panel-sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }

.table {
  --cols: minmax(220px, 2.2fr) repeat(5, minmax(84px, 1fr)) minmax(90px, 0.9fr) 76px;
}

.row {
  display: grid;
  grid-template-columns: var(--cols);
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  transition: background var(--fast);
}
.row:last-child { border-bottom: 0; }

.row-head {
  padding-top: 10px;
  padding-bottom: 10px;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.012);
}

.row-item { cursor: pointer; outline: none; }
.row-item:hover,
.row-item:focus-visible { background: var(--hover); }
.row-item:focus-visible { box-shadow: inset 2px 0 0 var(--text); }
.row-item.is-busy { pointer-events: auto; }
.row-item.is-busy .cell { opacity: 0.55; transition: opacity var(--base); }

.cell { min-width: 0; text-align: right; }
.cell:first-child { text-align: left; }
.cell-sub { display: block; color: var(--text-3); font-size: 12px; margin-top: 1px; }
.cell-value { font-size: 13.5px; }

.ident { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ident-text { min-width: 0; }
.ident-name { display: flex; align-items: center; gap: 7px; font-weight: 500; }
.ident-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ident-sub { color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  object-fit: cover;
}
.avatar-lg { width: 64px; height: 64px; border-radius: 16px; }
.avatar-fallback { display: grid; place-items: center; color: var(--text-3); }

.row-actions { display: flex; justify-content: flex-end; gap: 2px; opacity: 0.6; transition: opacity var(--fast); }
.row-item:hover .row-actions,
.row-item:focus-within .row-actions,
.row-item.is-busy .row-actions { opacity: 1; }

.is-green { color: var(--green); }
.is-amber { color: var(--amber); }
.is-red { color: var(--red); }

/* ==========================================================================
   Transfer meter — tone follows usage: green (<50%), amber (50–79%), red (80%+)
   ========================================================================== */
.is-low  { --tone: var(--green); --tone-bg: var(--green-bg); }
.is-mid  { --tone: var(--amber); --tone-bg: var(--amber-bg); }
.is-high { --tone: var(--red);   --tone-bg: var(--red-bg); }
.tone { color: var(--tone); }

.meter {
  position: relative;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}
.meter-fill {
  width: var(--pct);
  min-width: 4px;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--tone) 45%, transparent), var(--tone));
}

.meter-lg {
  height: 10px;
  margin-top: 18px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), rgba(255, 255, 255, 0.06) calc(25% - 1px) 25%),
    rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
.meter-lg .meter-fill {
  position: relative;
  box-shadow: 0 0 16px -2px var(--tone);
  transform-origin: left;
  animation: meter-grow 0.9s var(--ease) both;
}
.meter-lg .meter-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  background-size: 50% 100%;
  background-repeat: no-repeat;
  animation: meter-shine 2.6s ease-in-out 1s infinite;
}

.meter-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--text-3);
  font-size: 10.5px;
}

/* Table cell */
.transfer-cell { display: grid; justify-items: end; gap: 5px; }
.transfer-cell .meter { width: 100%; max-width: 92px; }
.transfer-cell .cell-sub { margin-top: -2px; }

/* Detail panel */
.transfer {
  position: relative;
  margin-top: 16px;
  padding: 18px 18px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--tone-bg), transparent 55%),
    var(--surface-2);
  overflow: hidden;
}
.transfer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.transfer-title { font-size: 13.5px; font-weight: 500; }
.transfer-status { display: flex; align-items: center; gap: 7px; margin-top: 4px; color: var(--text-2); font-size: 12.5px; }
.transfer-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--tone); box-shadow: 0 0 0 3px var(--tone-bg); }
.transfer-pct { font-size: 30px; font-weight: 500; line-height: 1; letter-spacing: -0.04em; }
.transfer-pct small { font-size: 15px; margin-left: 1px; opacity: 0.7; }

.transfer-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.transfer-stats > div + div { padding-left: 14px; border-left: 1px solid var(--line); }
.transfer-stats dt { color: var(--text-3); font-size: 11.5px; }
.transfer-stats dd { margin: 3px 0 0; font-size: 16px; font-weight: 500; letter-spacing: -0.02em; }

/* Unlock schedule */
.unlocks { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.unlocks-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: var(--text-2); font-size: 12.5px; font-weight: 500; }
.unlocks-head .num { color: var(--text-3); font-weight: 400; }

.timeline { display: grid; margin: 0; padding: 0; list-style: none; }
.step { position: relative; display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 12px; padding: 9px 0; }
.step::before { content: ''; position: absolute; left: 6.5px; top: 0; bottom: 0; width: 1px; background: var(--line-2); }
.step:first-child::before { top: 50%; }
.step:last-child::before { bottom: 50%; }
.step:only-child::before { display: none; }
.step-dot { position: relative; z-index: 1; justify-self: center; width: 9px; height: 9px; border-radius: 50%; background: var(--tone); box-shadow: 0 0 0 3px var(--tone-bg); }
.step-date { font-size: 13px; font-weight: 500; }
.step-eta { margin-top: 1px; color: var(--text-3); font-size: 12px; }
.step-side { text-align: right; }
.step-amount { color: var(--tone); font-size: 13.5px; font-weight: 500; }
.step-total { margin-top: 1px; color: var(--text-3); font-size: 12px; }

@keyframes meter-grow { from { transform: scaleX(0); } }
@keyframes meter-shine { from { background-position: -100% 0; } to { background-position: 200% 0; } }
.is-zero { color: var(--text-3); }

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid var(--line-2);
  color: var(--text-2);
}
.badge .icon { width: 12px; height: 12px; }
.badge-gold { color: var(--gold); background: var(--gold-bg); border-color: rgba(217, 191, 140, 0.18); }
.badge-amber { color: var(--amber); background: var(--amber-bg); border-color: rgba(233, 180, 90, 0.18); }
.badge-red { color: var(--red); background: var(--red-bg); border-color: rgba(236, 106, 106, 0.2); }
.badge-green { color: var(--green); background: var(--green-bg); border-color: rgba(95, 212, 160, 0.18); }

/* ==========================================================================
   Empty / skeleton
   ========================================================================== */
.empty { display: grid; justify-items: center; gap: 10px; padding: 72px 24px; text-align: center; }
.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text-2);
  margin-bottom: 6px;
}
.empty-icon .icon { width: 20px; height: 20px; }
.empty h3 { font-size: 15px; font-weight: 500; }
.empty p { color: var(--text-3); max-width: 360px; }
.empty .btn { margin-top: 10px; }

.skeleton {
  display: block;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}

/* ==========================================================================
   Dialogs (shared)
   ========================================================================== */
dialog {
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
  max-width: none;
  max-height: none;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
dialog[open]::backdrop { animation: fade-in var(--base) ease both; }
dialog.is-closing::backdrop { animation: fade-out 160ms ease both; }

body:has(dialog[open]) { overflow: hidden; }

/* Modal */
.modal { width: min(460px, calc(100vw - 32px)); margin: auto; }
.modal-sm { width: min(380px, calc(100vw - 32px)); }
.modal[open] { animation: modal-in var(--base) var(--ease) both; }
.modal.is-closing { animation: modal-out 160ms ease both; }

.modal-card {
  display: grid;
  gap: 18px;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  border: 1px solid var(--line-2);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.modal-head { display: grid; grid-template-columns: auto 1fr auto; align-items: start; gap: 14px; }
.modal-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  color: var(--text-2);
}
.modal-title { font-size: 16px; font-weight: 600; letter-spacing: -0.015em; }
.modal-sub { color: var(--text-2); margin-top: 3px; font-size: 13.5px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.field { display: grid; gap: 7px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--text-2); }
.field-label em { font-style: normal; color: var(--text-3); font-weight: 400; margin-left: 4px; }

.input {
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  outline: none;
  font-size: 13.5px;
  transition: border-color var(--fast), box-shadow var(--fast);
}
.input::placeholder { color: var(--text-3); }
.input:focus { border-color: var(--line-3); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05); }
.input-mono { font-family: var(--mono); font-size: 12.5px; }

.form-error {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--red-bg);
  border: 1px solid rgba(236, 106, 106, 0.2);
  color: var(--red);
  font-size: 13px;
}

/* Drawer */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(880px, 100vw);
  height: 100dvh;
  margin: 0;
  background: var(--surface);
  border-left: 1px solid var(--line-2);
  box-shadow: -40px 0 80px -30px rgba(0, 0, 0, 0.8);
}
.drawer[open] { animation: drawer-in 340ms var(--ease) both; }
.drawer.is-closing { animation: drawer-out 200ms ease both; }

.drawer-body { height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; }

.detail-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 22px 28px;
  background: rgba(13, 13, 15, 0.86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.detail-name { display: flex; align-items: center; gap: 8px; font-size: 19px; font-weight: 600; letter-spacing: -0.02em; }
.detail-sub { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--text-3); font-size: 13px; margin-top: 3px; }
.detail-sub > span { display: inline-flex; align-items: center; gap: 5px; }
.detail-sub .icon { width: 13px; height: 13px; }
.detail-actions { display: flex; gap: 4px; align-self: start; }

.detail-section { padding: 22px 28px; border-bottom: 1px solid var(--line); }
.detail-section:last-child { border-bottom: 0; }

.mini-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mini-stat { padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.mini-stat dt { color: var(--text-3); font-size: 12px; }
.mini-stat dd { margin: 6px 0 0; font-size: 18px; font-weight: 500; letter-spacing: -0.02em; }
.mini-stat small { display: block; color: var(--text-3); font-size: 12px; margin-top: 2px; font-family: var(--font); letter-spacing: 0; }

.label-field { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.label-field span { color: var(--text-3); font-size: 12.5px; }
.label-field .input { flex: 1; height: 34px; max-width: 280px; }

.alert {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.alert-red { color: var(--red); background: var(--red-bg); border: 1px solid rgba(236, 106, 106, 0.2); }

/* Pending sales */
.sale-list { display: grid; gap: 8px; }
.sale {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.sale-main { min-width: 0; }
.sale-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sale-sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.sale-side { text-align: right; }
.sale-amount { color: var(--amber); font-size: 15px; font-weight: 500; }
.sale-eta { color: var(--text-2); font-size: 12.5px; margin-top: 2px; }
.sale-meter { grid-column: 1 / -1; }

/* Communities */
.section-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 500; color: var(--text-2); margin-bottom: 14px; }
.section-title .icon { color: var(--text-3); }

.community-list { display: grid; gap: 8px; }
.community {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: border-color var(--fast), background var(--fast);
}
.community:hover { border-color: var(--line-3); background: var(--surface-3); }
.community-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--line); object-fit: cover; }
.community-ident { min-width: 0; }
.community-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.community-sub { color: var(--text-3); font-size: 12.5px; }
.community-stats { display: flex; gap: 22px; margin: 0; text-align: right; }
.community-stats dt { color: var(--text-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; font-family: var(--font); }
.community-stats dd { margin: 2px 0 0; font-size: 14px; }

/* Inventory */
.inventory-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.inventory-head .search input { width: 180px; }

.tabs { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--fast), color var(--fast);
}
.tab:hover { color: var(--text); }
.tab.is-active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 1px 2px rgba(0, 0, 0, 0.4); }
.tab-count { font-family: var(--mono); font-size: 11.5px; color: var(--text-3); }

.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }

.item {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
  transition: border-color var(--fast), transform var(--base) var(--ease), background var(--fast);
  content-visibility: auto;
  contain-intrinsic-size: auto 290px;
}
.item:hover { border-color: var(--line-3); transform: translateY(-2px); background: var(--surface-3); }
.item.is-hold { border-color: rgba(233, 180, 90, 0.16); }

.item-thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  margin: 6px 6px 0;
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 45%, rgba(255, 255, 255, 0.06), transparent 65%),
    var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
}
.item-thumb img {
  width: 74%;
  height: 74%;
  object-fit: contain;
  transition: transform var(--base) var(--ease);
}
.item:hover .item-thumb img { transform: scale(1.05); }
.item-placeholder { width: 28px; height: 28px; color: var(--text-3); }

.item-hold,
.item-serial {
  position: absolute;
  bottom: 7px;
  height: 20px;
  padding: 0 7px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(10, 10, 12, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line-2);
}
.item-hold { left: 7px; color: var(--amber); border-color: rgba(233, 180, 90, 0.25); }
.item-serial { right: 7px; color: var(--text-2); }

.item-link {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(10, 10, 12, 0.7);
  color: var(--text-2);
  opacity: 0;
  transition: opacity var(--fast);
}
.item-link .icon { width: 13px; height: 13px; }
.item:hover .item-link { opacity: 1; }

.item-body { display: flex; flex-direction: column; flex: 1; gap: 10px; padding: 10px 12px 12px; }
.item-title { min-width: 0; }
.item-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  min-height: 2.6em;
  overflow: hidden;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
}
.item-acronym { color: var(--text-3); font-size: 11.5px; margin-top: 2px; }

.item-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.item-stats > div + div { padding-left: 10px; border-left: 1px solid var(--line); }
.item-stats dt { color: var(--text-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; }
.item-stats dd { margin: 2px 0 0; font-size: 13.5px; }

.item-foot { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.item-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.demand { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 11.5px; }
.demand-bar { display: inline-flex; gap: 2px; }
.demand-bar i { width: 10px; height: 3px; border-radius: 2px; background: var(--line-2); }
.demand-bar i.on { background: var(--text-2); }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  display: grid;
  gap: 8px;
  justify-items: end;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 380px;
  padding: 11px 14px;
  border-radius: var(--radius);
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.8);
  font-size: 13.5px;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  transition: opacity var(--base) var(--ease), transform var(--base) var(--ease);
}
.toast.is-in { opacity: 1; transform: none; }
.toast::before { content: ''; width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--text-2); }
.toast-success::before { background: var(--green); }
.toast-error::before { background: var(--red); }

/* ==========================================================================
   Motion
   ========================================================================== */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes modal-out { to { opacity: 0; transform: translateY(4px) scale(0.98); } }
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes drawer-out { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ==========================================================================
   Finance
   ========================================================================== */
.month-nav { display: flex; align-items: center; gap: 4px; padding: 3px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--surface); }
.month-label { min-width: 108px; text-align: center; font-size: 13px; color: var(--text-2); }
.icon-flip { transform: rotate(90deg); }
.month-nav .icon:not(.icon-flip) { transform: rotate(-90deg); }

.finance { animation-delay: 0.18s; }

.finance-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 18px 20px 0; }

.finance-stat {
  display: grid;
  gap: 5px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.finance-stat-label { color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.finance-stat-value { font-size: 20px; font-weight: 500; letter-spacing: -0.02em; white-space: nowrap; font-variant-numeric: tabular-nums; }
.finance-stat-foot { color: var(--text-3); font-size: 12px; }

.finance-add {
  display: grid;
  grid-template-columns: 140px minmax(140px, 1.4fr) minmax(120px, 1fr) 150px auto;
  align-items: end;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.finance-submit { height: 40px; }
.finance-submit .icon { width: 15px; height: 15px; }

.finance-list { display: grid; }
.finance-row {
  display: grid;
  grid-template-columns: 1fr 160px 84px;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}
.finance-row:last-child { border-bottom: 0; }
.finance-row-head {
  color: var(--text-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 10px;
  padding-bottom: 10px;
}
.finance-row-head .finance-amount { justify-self: end; }

.finance-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.finance-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: currentColor; }
.finance-dot.is-green { color: var(--green); }
.finance-dot.is-red { color: var(--red); }
.finance-ident { display: grid; gap: 2px; min-width: 0; }
.finance-name { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.finance-date { color: var(--text-3); font-size: 12px; }
.finance-amount { justify-self: end; font-size: 13.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.finance-actions { display: flex; justify-content: flex-end; gap: 4px; }

.finance-row.is-editing { grid-template-columns: 1fr auto; align-items: end; }
.finance-edit-fields { display: grid; grid-template-columns: 1.4fr 1fr 150px 150px; gap: 12px; width: 100%; }

.finance-empty { padding: 28px 20px; color: var(--text-3); font-size: 13px; text-align: center; }

.finance-chart { margin: 0; padding: 18px 20px 20px; border-top: 1px solid var(--line); }
.finance-chart figcaption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-3);
  font-size: 12px;
  margin-bottom: 10px;
}
.finance-legend { display: inline-flex; align-items: center; gap: 6px; }
.finance-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.finance-legend i + i { margin-left: 10px; }
.legend-in { background: var(--green); }
.legend-out { background: var(--red); }
.finance-chart svg { width: 100%; height: 150px; overflow: visible; }
.chart-in { fill: var(--green); opacity: 0.85; }
.chart-out { fill: var(--red); opacity: 0.8; }
.chart-label { fill: var(--text-3); font-size: 10px; font-family: var(--font); }

.finance-loading { padding: 18px 20px; }

/* ==========================================================================
   Auth
   ========================================================================== */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

.auth { width: min(380px, 100%); }

.auth-card {
  display: grid;
  gap: 16px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line-2);
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.9);
  animation: rise 0.5s var(--ease) both;
}

.auth-head { display: grid; gap: 4px; margin-bottom: 4px; }
.auth-head .brand-name { font-size: 17px; }
.auth-sub { color: var(--text-3); font-size: 13px; }
.auth-submit { justify-content: center; margin-top: 4px; }

.select-block { width: 100%; height: 40px; }
.select-block select { width: 100%; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1200px) {
  .overview { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .community { grid-template-columns: auto 1fr; }
  .community-stats { grid-column: 1 / -1; justify-content: flex-start; text-align: left; }
}

@media (max-width: 1100px) {
  .finance-add { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-submit { grid-column: 1 / -1; justify-content: center; }
  .finance-edit-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 920px) {
  .row-head { display: none; }
  .row-item {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px 12px;
  }
  .row-item .cell { text-align: left; }
  .row-item .transfer-cell { justify-items: start; }
  .row-item .cell:first-child { grid-column: 1 / -2; }
  .row-item .row-actions { grid-column: -2 / -1; grid-row: 1; opacity: 1; }
  .row-item .cell[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--text-3);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
  }
  .mini-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .finance-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .finance-stat-value { font-size: 17px; }
  .finance-row { grid-template-columns: 1fr 120px 72px; padding-left: 18px; padding-right: 18px; }
  .finance-row.is-editing { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { width: 36px; padding: 0; }
  .brand { margin-right: auto; }
  .stat-value { font-size: 22px; }
  .toolbar, .search { width: 100%; }
  .search input { width: 100%; }
  .detail-head, .detail-section { padding-left: 18px; padding-right: 18px; }
  .inventory-head .search input { width: 100%; }
}
