/* ==========================================================
   Ledger — design tokens
   Dark, Tektur-driven theme: techy display type, deep neutrals,
   a bright accent, glass surfaces, quiet motion.
   ========================================================== */

:root {
  --bg:            #0A0A0E;
  --surface:       #17171D;
  --surface-alt:   #1E1E26;
  --border:        #2C2C36;
  --text:          #F2F2F5;
  --text-secondary:#A0A0AC;
  --text-tertiary: #6C6C78;

  --accent:        #4C8DFF;
  --accent-hover:  #6BA1FF;
  --accent-wash:   rgba(76, 141, 255, 0.16);

  --green:         #34D399;
  --green-wash:    rgba(52, 211, 153, 0.14);
  --red:           #F87171;
  --red-wash:      rgba(248, 113, 113, 0.14);
  --amber:         #FBBF6B;
  --amber-wash:    rgba(251, 191, 107, 0.14);
  --purple:        #B39DFF;
  --purple-wash:   rgba(179, 157, 255, 0.16);

  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 9px;

  --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.35);
  --shadow-pop:  0 2px 8px rgba(0,0,0,0.4), 0 16px 40px rgba(0,0,0,0.5);

  --font: "Tektur", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Menlo", "Consolas", monospace;
}

* { box-sizing: border-box; }

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

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

h1, h2, h3, h4 { margin: 0 0 4px 0; letter-spacing: -0.01em; font-weight: 600; }
h1 { font-size: 30px; letter-spacing: -0.02em; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p  { margin: 0 0 12px 0; color: var(--text-secondary); }

::selection { background: var(--accent-wash); color: var(--accent); }

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

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

/* ---------------- Layout shell ---------------- */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 20px 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand .mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(155deg, #4C8DFF, #B39DFF);
  display: inline-block;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 14px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: var(--bg); color: var(--text); }
.nav-link.active { background: var(--accent-wash); color: var(--accent); }
.nav-link svg { flex-shrink: 0; opacity: 0.9; }

.sidebar .spacer { flex: 1; }

.sidebar .user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-wash); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px;
}

.main {
  padding: 32px 40px 60px 40px;
  max-width: 1080px;
}

.topbar {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 28px;
}
.topbar .subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 2px; }

/* ---------------- Cards ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 24px;
}

.card + .card { margin-top: 20px; }

.grid {
  display: grid;
  gap: 20px;
}
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 900px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

.stat-card .label {
  font-size: 13px; color: var(--text-secondary); font-weight: 500; margin-bottom: 6px;
}
.stat-card .value {
  font-size: 28px; font-weight: 600; letter-spacing: -0.02em;
}
.stat-card .delta { font-size: 13px; margin-top: 4px; font-weight: 500; }
.delta.up { color: var(--green); }
.delta.down { color: var(--red); }

.hero-value {
  font-size: 52px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* ---------------- Buttons & forms ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: 980px;
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, border-color .15s ease;
  font-family: var(--font);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger { background: var(--red-wash); color: var(--red); }
.btn-danger:hover { background: rgba(248, 113, 113, 0.24); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; color: var(--text);
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
.field .hint { font-size: 12px; color: var(--text-tertiary); margin-top: 5px; }

.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 600px at 20% 0%, rgba(76,141,255,0.14) 0%, transparent 60%),
    radial-gradient(1200px 600px at 100% 100%, rgba(179,157,255,0.12) 0%, transparent 60%),
    var(--bg);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 36px;
}
.auth-card .mark { width: 40px; height: 40px; border-radius: 11px; margin-bottom: 18px;
  background: linear-gradient(155deg, #4C8DFF, #B39DFF); }

/* ---------------- Table ---------------- */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 500; color: var(--text-secondary);
  padding: 10px 12px; border-bottom: 1px solid var(--border);
}
td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num { font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 980px;
  font-size: 12px; font-weight: 600;
}
.pill-green  { background: var(--green-wash); color: var(--green); }
.pill-red    { background: var(--red-wash);   color: var(--red); }
.pill-amber  { background: var(--amber-wash); color: var(--amber); }
.pill-purple { background: var(--purple-wash);color: var(--purple); }
.pill-gray   { background: var(--bg); color: var(--text-secondary); }

.mono { font-family: var(--font-mono); font-size: 13px; }

.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-secondary);
}

.banner {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 20px;
}
.banner-error { background: var(--red-wash); color: var(--red); }
.banner-success { background: var(--green-wash); color: var(--green); }
.banner-info { background: var(--accent-wash); color: var(--accent); }

.section-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}

code, .code-block {
  font-family: var(--font-mono);
  font-size: 13px;
}
.code-block {
  background: #000000; color: #F2F2F5; border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px; overflow-x: auto; white-space: pre;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  display: none; align-items: center; justify-content: center; z-index: 50;
  backdrop-filter: blur(4px);
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop); padding: 28px; width: 100%; max-width: 460px;
}

.key-reveal {
  background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-sm);
  padding: 14px; margin: 14px 0;
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: normal;
  max-width: 100%;
  line-height: 1.6;
}

.key-cell {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.mt-0 { margin-top: 0; }

/* Keep the trading lab and administration usable on phones and small laptops. */
.main { min-width: 0; width: 100%; }
@media (max-width: 720px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; display: flex; flex-direction: row; flex-wrap: wrap; padding: 14px; gap: 4px; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar .brand { width: 100%; padding-bottom: 8px; }
  .sidebar .nav-link { font-size: 12px; padding: 7px 9px; }
  .sidebar .spacer { display: none; }
  .sidebar .user-chip { margin-top: 8px; width: 100%; }
  .main { padding: 24px 16px 40px; }
  .card { padding: 18px; }
  .topbar { align-items: flex-start; gap: 12px; flex-wrap: wrap; }
  .hero-value { font-size: 40px; }
}
