/* ============================================================
   DELTA ONE — Redesign Design System (Ledger Dashboard Aesthetic)
   Direction: High-contrast crypto ops terminal.
   Fonts: Bricolage Grotesque (display/headings/KPI values) +
          JetBrains Mono (body/numbers/tables/micro-data).
   Colors: Lime accent (#c8ff4d in dark, #5c8a12 in light),
          deep surface panels, crisp borders.
   ============================================================ */

:root {
  --bg: #0a0a0b;
  --surface: #131316;
  --surface-2: #19191d;
  --surface-3: #202024;
  --border: #26262b;
  --border-hi: #333338;
  --text: #eceef0;
  --text-dim: #9a9aa2;
  --text-faint: #5c5c64;
  --accent: #c8ff4d;
  --accent-dim: #8fb336;
  --accent-glow: rgba(200, 255, 77, 0.12);
  --red: #ff5c5c;
  --red-dim: rgba(255, 92, 92, 0.12);
  --blue: #5eb1ff;
  --bg-rgb: 10, 10, 11;
  --radius: 14px;
  --radius-sm: 9px;
  font-family: 'JetBrains Mono', monospace;
}

html[data-theme="light"] {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --surface-3: #e6e6e1;
  --border: #e2e2dc;
  --border-hi: #cfcfc7;
  --text: #17171a;
  --text-dim: #5c5c63;
  --text-faint: #96968f;
  --accent: #5c8a12;
  --accent-dim: #4a7010;
  --accent-glow: rgba(92, 138, 18, 0.10);
  --red: #c93838;
  --red-dim: rgba(201, 56, 56, 0.08);
  --blue: #2a72c9;
  --bg-rgb: 246, 246, 243;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

body {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(circle at 15% 0%, rgba(200, 255, 77, 0.05) 0%, transparent 35%),
    radial-gradient(circle at 85% 100%, rgba(94, 177, 255, 0.04) 0%, transparent 40%);
  background-attachment: fixed;
}

html[data-theme="light"] body {
  background-image:
    radial-gradient(circle at 15% 0%, rgba(92, 138, 18, 0.06) 0%, transparent 35%),
    radial-gradient(circle at 85% 100%, rgba(42, 114, 201, 0.05) 0%, transparent 40%);
}

h1, h2, h3, .display {
  font-family: 'Bricolage Grotesque', sans-serif;
  letter-spacing: -0.02em;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 8px; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ---------- APP LAYOUT & SIDEBAR (Direct from ledger-dashboard.html) ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 40;
  transition: width 0.2s ease;
}

.sidebar-toggle {
  position: absolute; top: 64px; right: -12px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); cursor: pointer; z-index: 41;
}
.sidebar-toggle:hover { background: var(--surface-3); color: var(--text); }
.sidebar-toggle svg { width: 13px; height: 13px; transition: transform 0.2s ease; }

.brand {
  padding: 22px 20px 18px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), #7fbf2e);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: #0a0a0b; font-family: 'Bricolage Grotesque', sans-serif; font-size: 16px;
  box-shadow: 0 0 20px var(--accent-glow);
}
html[data-theme="light"] .brand-mark { color: #ffffff; }
.brand-name { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 17px; }
.brand-sub { font-size: 10px; color: var(--text-faint); letter-spacing: 0.08em; text-transform: uppercase; margin-top: 1px; }
.brand-tag {
  font-size: 9px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  background: var(--surface-3); border: 1px solid var(--border-hi); color: var(--text-dim); margin-left: 4px;
}

.nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overflow-x: hidden; }
.nav-section {
  font-size: 9.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 700; padding: 14px 12px 6px; white-space: nowrap;
}
.nav-section:first-child { padding-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: 13px; font-weight: 500; border: 1px solid transparent;
  transition: all 0.15s ease; background: none; width: 100%; text-align: left; white-space: nowrap;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-glow); color: var(--accent); border-color: rgba(200, 255, 77, 0.18); }
.nav-item.active svg { opacity: 1; }

.nav-foot { padding: 14px 20px 20px; border-top: 1px solid var(--border); overflow: hidden; }
.sync-pill { display: flex; align-items: center; gap: 7px; font-size: 10.5px; color: var(--text-faint); white-space: nowrap; }
.dot { width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: var(--accent); box-shadow: 0 0 8px var(--accent); animation: pulse 2s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* Collapsed Sidebar */
#appRoot.sidebar-collapsed .sidebar { width: 68px; }
#appRoot.sidebar-collapsed .main { margin-left: 68px; }
#appRoot.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
#appRoot.sidebar-collapsed .brand { padding: 22px 0 18px; justify-content: center; }
#appRoot.sidebar-collapsed .brand-text,
#appRoot.sidebar-collapsed .brand-sub,
#appRoot.sidebar-collapsed .nav-section,
#appRoot.sidebar-collapsed .nav-label,
#appRoot.sidebar-collapsed .brand-tag,
#appRoot.sidebar-collapsed .sync-text,
#appRoot.sidebar-collapsed .pill-text { display: none; }
#appRoot.sidebar-collapsed .nav-item { justify-content: center; padding: 10px 0; gap: 0; }
#appRoot.sidebar-collapsed .sync-pill { justify-content: center; }
#appRoot.sidebar-collapsed .nav-foot .btn { padding: 9px 0; }

/* Main Content & Sticky Topbar (Direct from ledger-dashboard.html) */
.main { flex: 1; margin-left: 230px; min-height: 100vh; display: flex; flex-direction: column; transition: margin-left 0.2s ease; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: rgba(var(--bg-rgb), 0.85); backdrop-filter: blur(10px); z-index: 30;
  gap: 16px; flex-wrap: wrap;
}
.topbar h1 { font-size: 22px; font-weight: 700; }
.topbar-sub { color: var(--text-faint); font-size: 12px; margin-top: 2px; }
.topbar-right { display: flex; gap: 14px; align-items: center; flex-shrink: 0; }
.content { padding: 28px 32px 60px; flex: 1; width: 100%; box-sizing: border-box; }

/* Buttons & Controls */
.btn {
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--border-hi); background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; gap: 7px; transition: all 0.15s ease;
}
.btn:hover { background: var(--surface-3); border-color: #3d3d44; }
.btn-primary { background: var(--accent); color: #0a0a0b; border-color: var(--accent); font-weight: 700; }
html[data-theme="light"] .btn-primary { color: #0a0a0b; font-weight: 700; }
.btn-primary:hover { background: #d4ff6b; box-shadow: 0 0 24px var(--accent-glow); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-dim); border-color: rgba(255, 92, 92, 0.3); }
.btn-sm { padding: 6px 11px; font-size: 11.5px; }

.theme-toggle {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border-hi);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-dim); flex-shrink: 0; transition: all 0.15s ease; cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent-dim); }
.theme-toggle svg { width: 17px; height: 17px; }

/* KPI Grid Cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 24px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 24px; }

.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 17px; position: relative; overflow: hidden;
}
.kpi-label { font-size: 10.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 9px; }
.kpi-value { font-family: 'Bricolage Grotesque', sans-serif; font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
.kpi-delta { font-size: 11px; margin-top: 7px; font-weight: 600; }
.kpi-delta.up { color: var(--accent); }
.kpi-delta.down { color: var(--red); }

/* Panels & Layout Grids */
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2-equal { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2 > div, .grid-2-equal > div, .grid-3 > div { display: flex; flex-direction: column; gap: 16px; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-title { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 15px; }

/* Data Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th {
  text-align: left; color: var(--text-faint); font-weight: 600; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: 0.06em; padding: 0 12px 10px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }

/* Badges & Status Pills */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px;
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-participate { background: var(--accent-glow); color: var(--accent); }
.badge-watchlist { background: rgba(94, 177, 255, 0.12); color: var(--blue); }
.badge-completed { background: var(--surface-3); color: var(--text-dim); }
.badge-avoid { background: var(--red-dim); color: var(--red); }
.badge-priority-high { background: var(--red-dim); color: var(--red); }
.badge-priority-medium { background: rgba(94, 177, 255, 0.12); color: var(--blue); }
.badge-priority-low { background: var(--surface-3); color: var(--text-dim); }

.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 0; }
.filter-pill {
  padding: 7px 13px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  display: flex; align-items: center; gap: 6px; cursor: pointer; transition: all 0.15s ease;
}
.filter-pill:hover { border-color: var(--border-hi); color: var(--text); }
.filter-pill.active { background: var(--accent-glow); border-color: rgba(200, 255, 77, 0.3); color: var(--accent); }
.filter-pill .count {
  background: var(--surface-3); padding: 1px 6px; border-radius: 10px; font-size: 10px; color: var(--text-faint);
}
.filter-pill.active .count {
  background: rgba(200, 255, 77, 0.18); color: var(--accent);
}

select, .sort-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a9aa2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  border: 1px solid var(--border-hi);
  color: var(--text);
  padding: 7px 30px 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-family: inherit;
  outline: none;
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: auto;
}

html[data-theme="light"] select, html[data-theme="light"] .sort-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c5c63' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

select:hover, .sort-select:hover {
  border-color: var(--accent);
  color: var(--text);
}

select option, .sort-select option {
  background-color: var(--surface);
  color: var(--text);
  padding: 8px 12px;
}

.search-bar-input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  color: var(--text); padding: 10px 16px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 12.5px; margin-bottom: 12px; outline: none; transition: border-color 0.15s ease;
}
.search-bar-input:focus { border-color: var(--border-hi); }

/* Command Palette (`⌘/Ctrl K` Modal) */
.cmd-overlay {
  position: fixed; inset: 0; background: rgba(6, 6, 7, 0.7); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 60px 16px;
}
.cmd-overlay.show { display: flex; }
.cmd-modal {
  background: var(--surface); border: 1px solid var(--border-hi); border-radius: var(--radius);
  width: 100%; max-width: 560px; overflow: hidden; animation: pop 0.18s ease; box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.cmd-input {
  width: 100%; background: none; border: none; color: var(--text); font-size: 14px;
  font-family: inherit; outline: none; padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.cmd-results { max-height: 380px; overflow-y: auto; padding: 8px; }
.cmd-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 12.5px;
}
.cmd-item:hover, .cmd-item.sel { background: var(--accent-glow); color: var(--accent); }
.cmd-type {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint);
  background: var(--surface-3); padding: 3px 8px; border-radius: 10px; flex-shrink: 0; width: 70px; text-align: center;
}
.cmd-label { font-weight: 600; flex: 1; }

/* Modals & Forms */
.overlay {
  position: fixed; inset: 0; background: rgba(6, 6, 7, 0.7); backdrop-filter: blur(4px);
  display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow-y: auto;
}
.overlay.show { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border-hi); border-radius: var(--radius);
  width: 100%; max-width: 520px; padding: 24px; animation: pop 0.18s ease;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-title { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 17px; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-dim); cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface-3); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 11px; color: var(--text-dim); margin-bottom: 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border-hi); color: var(--text);
  padding: 10px 12px; border-radius: 8px; font-family: inherit; font-size: 12.5px;
}
.field select, select, .sort-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: var(--surface-2) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888890' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 12px 12px !important;
  padding-right: 32px !important;
  cursor: pointer;
}
.field select option, select option {
  background: var(--surface-2);
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Scrollbar Hiding Utility */
.hide-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.hide-scrollbar::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

/* Toasts */
#toastRoot {
  position: fixed; bottom: 24px; right: 24px; z-index: 2000;
  display: flex; flex-direction: column-reverse; gap: 10px; max-width: 480px; width: calc(100vw - 48px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--surface-2); border: 1px solid var(--border-hi);
  padding: 14px 18px; border-radius: 12px; font-size: 12.5px; display: flex; align-items: flex-start; gap: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6); animation: slidein 0.2s ease; width: 100%; word-break: break-word;
}
@keyframes slidein { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.err { border-color: rgba(255, 92, 92, 0.5); color: #ff6b6b; background: rgba(30, 15, 18, 0.95); }
.toast.succ { border-color: rgba(200, 255, 77, 0.5); color: var(--accent); background: rgba(18, 28, 12, 0.95); }
html[data-theme="light"] .toast.err { background: #fff0f0; border-color: rgba(255, 92, 92, 0.5); color: #d32f2f; }
html[data-theme="light"] .toast.succ { background: #f4fce8; border-color: rgba(92, 177, 40, 0.5); color: #2e7d32; }

/* Keyboard key tags */
kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 6px;
  background: var(--surface-3); border: 1px solid var(--border-hi); border-bottom-width: 2px; border-radius: 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700; color: var(--text);
}

@media (max-width: 860px) {
  .grid-2, .grid-2-equal, .grid-3 { grid-template-columns: 1fr; }
  .topbar { padding: 16px 20px; }
  .content { padding: 20px; }
}
