/* ============================================================================
   xTriel Vault — design system. Dark-only. Uses the xtriel Linear tokens
   verbatim so the vault reads as the same product. No inline styles (strict CSP).
   ============================================================================ */

:root {
  /* surfaces */
  --canvas: #08090a;
  --canvas-deep: #010102;
  --s1: #0f1011;
  --s2: #141516;
  --s3: #18191a;
  --s4: #191a1b;
  /* text */
  --tp: #f7f8f8;
  --ts: #d0d6e0;
  --tt: #8a8f98;
  --tq: #7b7f88;
  /* accent (interactive only) */
  --accent: #2F6BFF;
  --accent-h: #4f86ff;
  /* hairlines / borders */
  --hl-micro: rgba(255, 255, 255, 0.02);
  --hl-sub: rgba(255, 255, 255, 0.05);
  --hl: rgba(255, 255, 255, 0.08);
  --hl-2: rgba(255, 255, 255, 0.12);
  /* data colours — status/trading only */
  --d-green: #4ade80;
  --d-red: #ff6b66;
  --d-amber: #ffb020;
  --d-blue: #5b8cff;
  /* type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* radius */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;
  /* motion */
  --dur-micro: 130ms;
  --dur-state: 200ms;
  --ease: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--canvas);
  color: var(--tp);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }

.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--tt); }
.faint { color: var(--tq); }
.small { font-size: 0.82rem; }

/* data-colour helpers — status affordances + trading data only */
.pos { color: var(--d-green); }
.neg { color: var(--d-red); }
.warn { color: var(--d-amber); }

/* ─── Layout shells ───────────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--canvas-deep);
  border-right: 1px solid var(--hl-sub);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 1.05rem;
  padding: 4px 8px 20px;
}
.brand .logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--s3);
  border: 1px solid var(--hl);
  display: grid; place-items: center;
  color: var(--accent);
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px; border-radius: var(--r-sm);
  color: var(--ts); cursor: pointer; font-size: 0.92rem;
  transition: background var(--dur-micro) var(--ease), color var(--dur-micro) var(--ease);
  border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.045); color: var(--tp); }
.nav-item.active { background: rgba(255, 255, 255, 0.06); color: var(--tp); }
.nav-item svg { width: 17px; height: 17px; opacity: 0.85; flex-shrink: 0; }
.nav-spacer { flex: 1; }

.main {
  padding: 32px 40px;
  max-width: 1100px;
  width: 100%;
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 26px;
}
.page-head .sub { color: var(--tt); font-size: 0.9rem; margin-top: 4px; }

/* centred auth/setup pages */
.center-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.center-card {
  width: 100%;
  max-width: 420px;
}

/* ─── Cards / tiles ───────────────────────────────────────────────────────── */

.card {
  background: var(--s1);
  border: 1px solid var(--hl-sub);
  border-radius: var(--r-lg);
  padding: 24px;
}
.card + .card { margin-top: 18px; }
.card-title { font-size: 0.95rem; font-weight: 600; margin-bottom: 4px; }
.card-sub { color: var(--tt); font-size: 0.85rem; margin-bottom: 18px; }

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.tile {
  background: var(--s1);
  border: 1px solid var(--hl-sub);
  border-radius: var(--r-md);
  padding: 18px 18px 16px;
}
.tile .label { color: var(--tt); font-size: 0.8rem; }
.tile .value { font-family: var(--mono); font-size: 1.7rem; font-weight: 600; margin-top: 8px; letter-spacing: -0.02em; }
.tile .value.sm { font-size: 1.15rem; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 0.82rem; color: var(--ts); margin-bottom: 6px; }
.field .hint { font-size: 0.76rem; color: var(--tq); margin-top: 5px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], textarea, select {
  width: 100%;
  background: var(--canvas);
  border: 1px solid var(--hl);
  border-radius: var(--r-sm);
  color: var(--tp);
  font-family: var(--font);
  font-size: 0.92rem;
  padding: 10px 12px;
  transition: border-color var(--dur-micro) var(--ease), box-shadow var(--dur-micro) var(--ease);
}
input.mono, textarea.mono { font-family: var(--mono); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, 0.16);
}
textarea { resize: vertical; min-height: 72px; }
input::placeholder, textarea::placeholder { color: var(--tq); }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 15px; border-radius: var(--r-sm);
  font-family: var(--font); font-size: 0.88rem; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: background var(--dur-micro) var(--ease), border-color var(--dur-micro) var(--ease), opacity var(--dur-micro) var(--ease);
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-h); }
.btn-secondary { background: var(--s2); color: var(--tp); border-color: var(--hl); }
.btn-secondary:hover:not(:disabled) { background: var(--s3); border-color: var(--hl-2); }
.btn-ghost { background: transparent; color: var(--ts); }
.btn-ghost:hover:not(:disabled) { background: var(--s2); color: var(--tp); }
.btn-danger { background: transparent; color: var(--d-red); border-color: rgba(255, 107, 102, 0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(255, 107, 102, 0.1); }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; }

.btn-row { display: flex; gap: 10px; margin-top: 20px; }
.btn-row.end { justify-content: flex-end; }

/* ─── Item list ───────────────────────────────────────────────────────────── */

.toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.toolbar .search { flex: 1; position: relative; }
.toolbar .search input { padding-left: 34px; }
.toolbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--tt); pointer-events: none; }

.item-list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 14px;
  background: var(--s1);
  border: 1px solid var(--hl-sub);
  border-radius: var(--r-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color var(--dur-micro) var(--ease), background var(--dur-micro) var(--ease);
}
.item:hover { background: var(--s2); border-color: var(--hl); }
.item .avatar {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  background: var(--s3); border: 1px solid var(--hl);
  display: grid; place-items: center; color: var(--tt);
  font-family: var(--mono); font-size: 0.9rem; flex-shrink: 0;
}
.item .info { flex: 1; min-width: 0; }
.item .info .name { font-weight: 500; font-size: 0.94rem; }
.item .info .meta { color: var(--tt); font-size: 0.8rem; margin-top: 2px; }
.item .info .meta .num { color: var(--ts); }
.item .badge-row { display: flex; gap: 6px; align-items: center; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.72rem; padding: 3px 8px; border-radius: var(--r-pill);
  background: var(--s3); color: var(--tt); border: 1px solid var(--hl-sub);
}
.badge.stale { color: var(--d-amber); border-color: rgba(255, 176, 32, 0.25); }
.badge.ok { color: var(--d-green); border-color: rgba(74, 222, 128, 0.22); }

.empty {
  text-align: center; padding: 60px 20px; color: var(--tt);
}
.empty svg { width: 40px; height: 40px; opacity: 0.4; margin-bottom: 14px; }

/* ─── Field rows (detail / reveal) ────────────────────────────────────────── */

.kv { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--hl-sub); }
.kv:last-child { border-bottom: none; }
.kv .k { font-size: 0.76rem; color: var(--tt); text-transform: uppercase; letter-spacing: 0.04em; }
.kv .v-row { display: flex; align-items: center; gap: 8px; }
.kv .v { font-family: var(--mono); font-size: 0.92rem; color: var(--tp); flex: 1; word-break: break-all; }
.kv .v.secret { letter-spacing: 0.06em; }
.reveal-btn, .copy-btn {
  background: var(--s2); border: 1px solid var(--hl); color: var(--ts);
  border-radius: 6px; padding: 5px 8px; cursor: pointer; font-size: 0.75rem;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background var(--dur-micro) var(--ease);
}
.reveal-btn:hover, .copy-btn:hover { background: var(--s3); color: var(--tp); }

/* ─── Modal ───────────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(1, 1, 2, 0.7);
  display: none; align-items: flex-start; justify-content: center;
  padding: 48px 20px; overflow-y: auto; z-index: 50;
  backdrop-filter: blur(2px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--s1); border: 1px solid var(--hl);
  border-radius: var(--r-lg); width: 100%; max-width: 480px;
  box-shadow: 0 24px 70px -24px #000;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--hl-sub); }
.modal-head h2 { font-size: 1.05rem; }
.modal-body { padding: 20px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--hl-sub); display: flex; gap: 10px; justify-content: flex-end; }
.x-btn { background: none; border: none; color: var(--tt); cursor: pointer; padding: 4px; border-radius: 6px; }
.x-btn:hover { background: var(--s2); color: var(--tp); }

/* ─── Steps (setup wizard) ────────────────────────────────────────────────── */

.steps { display: flex; gap: 8px; margin-bottom: 24px; }
.step-dot { flex: 1; height: 4px; border-radius: 3px; background: var(--hl); }
.step-dot.done { background: var(--accent); }
.step-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--s3);
  border: 1px solid var(--hl); display: grid; place-items: center;
  font-size: 0.8rem; color: var(--tt); flex-shrink: 0;
}

/* recovery code display */
.recovery-code {
  font-family: var(--mono); font-size: 1.05rem; letter-spacing: 0.05em;
  background: var(--canvas-deep); border: 1px solid var(--hl);
  border-radius: var(--r-sm); padding: 16px; text-align: center;
  color: var(--d-amber); word-break: break-all; margin: 8px 0 4px;
}
.callout {
  border-radius: var(--r-sm); padding: 12px 14px; font-size: 0.84rem;
  border: 1px solid var(--hl-sub); background: var(--s1); color: var(--ts);
  display: flex; gap: 10px; align-items: flex-start;
}
.callout.warn { border-color: rgba(255, 176, 32, 0.28); background: rgba(255, 176, 32, 0.06); }
.callout.danger { border-color: rgba(255, 107, 102, 0.28); background: rgba(255, 107, 102, 0.06); }
.callout svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }

/* qr/secret box */
.secret-box {
  font-family: var(--mono); font-size: 0.95rem; letter-spacing: 0.08em;
  background: var(--canvas-deep); border: 1px solid var(--hl);
  border-radius: var(--r-sm); padding: 14px; text-align: center;
  color: var(--tp); word-break: break-all;
}

/* ─── Toasts ──────────────────────────────────────────────────────────────── */

.toasts { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 100; }
.toast {
  background: var(--s2); border: 1px solid var(--hl);
  border-radius: var(--r-sm); padding: 12px 16px; font-size: 0.86rem;
  color: var(--tp); box-shadow: 0 12px 40px -16px #000;
  display: flex; align-items: center; gap: 10px; min-width: 220px; max-width: 360px;
  animation: toast-in var(--dur-state) var(--ease);
}
.toast.ok { border-color: rgba(74, 222, 128, 0.3); }
.toast.err { border-color: rgba(255, 107, 102, 0.35); }
.toast .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.toast.ok .dot { background: var(--d-green); }
.toast.err .dot { background: var(--d-red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ─── misc ────────────────────────────────────────────────────────────────── */

.spinner {
  width: 16px; height: 16px; border: 2px solid var(--hl-2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* Utility classes — kept in the stylesheet (not inline) so the strict
   style-src 'self' CSP holds with no inline-style violations. */
.center { justify-content: center; }
.text-center { text-align: center; }
.w-auto { width: auto; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mt-18 { margin-top: 18px; }
.mb-12 { margin-bottom: 12px; }
.mb-18 { margin-bottom: 18px; }
.ack { display: flex; gap: 9px; align-items: flex-start; margin-top: 16px; font-size: 0.86rem; color: var(--ts); cursor: pointer; }
.ack input { width: auto; margin-top: 3px; }
.divider { height: 1px; background: var(--hl-sub); margin: 18px 0; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.err-text { color: var(--d-red); font-size: 0.83rem; margin-top: 10px; min-height: 1em; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .nav-spacer { display: none; }
  .main { padding: 22px 18px; }
}

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