
/* =====================================================
   1. GLOBAL DESIGN TOKENS
   Change these values to redesign the entire website.
   ===================================================== */

:root {
  color-scheme: dark;

  --bg: #080d17;
  --sidebar: #0d1421;
  --surface: #111827;
  --surface-2: #151f30;
  --surface-3: #1b2a40;

  --text: #e7edf7;
  --muted: #8996ab;
  --border: #253147;

  --accent: #648cff;
  --accent-hover: #4c78ed;
  --accent-soft: #1c2d50;

  --green: #21d69a;
  --red: #ff657a;
  --yellow: #f4c76a;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 16px;

  --font-size: 14px;
  --control-height: 40px;

  --shadow: 0 8px 24px rgba(0,0,0,.18);
  --transition: 180ms ease;
}

/* LIGHT THEME */

html[data-theme="light"] {
  color-scheme: light;

  --bg: #f1f5f9;
  --sidebar: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #e8eef6;

  --text: #172033;
  --muted: #64748b;
  --border: #dce4ef;

  --accent: #3867db;
  --accent-hover: #2853bc;
  --accent-soft: #e6edff;

  --green: #059669;
  --red: #dc4055;
  --yellow: #a76b08;

  --shadow: 0 8px 24px rgba(15,23,42,.06);
}

/* SYSTEM THEME */

@media (prefers-color-scheme: light) {
  html[data-theme="system"] {
    color-scheme: light;

    --bg: #f1f5f9;
    --sidebar: #ffffff;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #e8eef6;

    --text: #172033;
    --muted: #64748b;
    --border: #dce4ef;

    --accent: #3867db;
    --accent-hover: #2853bc;
    --accent-soft: #e6edff;

    --green: #059669;
    --red: #dc4055;
    --yellow: #a76b08;

    --shadow: 0 8px 24px rgba(15,23,42,.06);
  }
}

/* =====================================================
   2. BASE STYLES
   ===================================================== */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
  font-size: var(--font-size);
  transition: background var(--transition), color var(--transition);
}

button, input, select, textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

h1, h2, h3, p {
  margin-top: 0;
}

h1 {
  font-size: 26px;
  margin-bottom: 8px;
}

h2 {
  font-size: 17px;
  margin-bottom: 16px;
}

h3 {
  font-size: 14px;
  margin-bottom: 12px;
}

small, .muted {
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* =====================================================
   3. LAYOUT
   ===================================================== */

.app {
  display: grid;
  grid-template-columns: 230px minmax(0,1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
}

.brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -1px;
  margin: 0 10px 4px;
}

.brand span {
  color: var(--green);
}

.brand-sub {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 2px;
  margin: 0 10px 30px;
}

.nav-label {
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin: 22px 10px 10px;
}

.nav-item {
  display: block;
  width: 100%;
  border: 0;
  text-align: left;
  padding: 12px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  transition: var(--transition);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

main {
  min-width: 0;
}

.topbar {
  min-height: 66px;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  border-bottom: 1px solid var(--border);
  background: var(--sidebar);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.content {
  max-width: 1600px;
  margin: auto;
  padding: 28px;
}

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 25px;
}

.page-heading p {
  color: var(--muted);
  margin-bottom: 0;
}

.grid {
  display: grid;
  gap: 18px;
}

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

.grid-3 {
  grid-template-columns: repeat(3,minmax(0,1fr));
}

.grid-4 {
  grid-template-columns: repeat(4,minmax(0,1fr));
}

.section {
  margin-top: 28px;
}

.card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-header h2 {
  margin: 0;
}

/* =====================================================
   4. BUTTONS
   ===================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--control-height);
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  transition: var(--transition);
}

.btn:hover {
  border-color: var(--accent);
  filter: brightness(1.04);
}

.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-success {
  background: var(--green);
  border-color: var(--green);
  color: #062b20;
}

.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: white;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-outline {
  background: transparent;
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.btn-lg {
  min-height: 48px;
  padding: 0 22px;
  font-size: 15px;
}

.btn-icon {
  width: var(--control-height);
  padding: 0;
}

/* =====================================================
   5. FORM CONTROLS
   ===================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.field label,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: var(--control-height);
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
}

.textarea {
  min-height: 90px;
  resize: vertical;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
  opacity: .7;
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.input-error {
  border-color: var(--red);
}

.input-success {
  border-color: var(--green);
}

.help-text {
  color: var(--muted);
  font-size: 11px;
}

.error-text {
  color: var(--red);
  font-size: 11px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 16px;
}

.check-row,
.radio-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 28px;
}

input[type="checkbox"],
input[type="radio"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
  cursor: pointer;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 30px;
  position: relative;
  transition: var(--transition);
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: var(--transition);
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.range {
  width: 100%;
  accent-color: var(--accent);
}

.segmented {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.segmented button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 13px;
  border-radius: 4px;
}

.segmented button.active {
  background: var(--accent);
  color: white;
}

/* =====================================================
   6. BADGES, ALERTS AND PROGRESS
   ===================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.badge-green {
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
  color: var(--green);
}

.badge-red {
  background: color-mix(in srgb, var(--red) 14%, var(--surface));
  color: var(--red);
}

.badge-yellow {
  background: color-mix(in srgb, var(--yellow) 14%, var(--surface));
  color: var(--yellow);
}

.alert {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  line-height: 1.6;
}

.alert-success {
  border-color: var(--green);
}

.alert-warning {
  border-color: var(--yellow);
}

.alert-danger {
  border-color: var(--red);
}

.progress {
  height: 8px;
  background: var(--surface-3);
  border-radius: 20px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 65%;
  background: var(--accent);
  border-radius: inherit;
}

/* =====================================================
   7. TABLES AND TRADING COMPONENTS
   ===================================================== */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th {
  text-align: left;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 13px;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 13px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

tbody tr:hover {
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.price {
  font-size: 26px;
  font-weight: 800;
}

.metric {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  font-size: 23px;
  font-weight: 700;
  margin: 10px 0;
}

.positive { color: var(--green); }
.negative { color: var(--red); }
.warning { color: var(--yellow); }

/* =====================================================
   8. TABS AND ACCORDION
   ===================================================== */

.tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.tab {
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 12px 2px;
}

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px;
  background: var(--surface-2);
}

details summary {
  cursor: pointer;
  font-weight: 600;
}

details p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

/* =====================================================
   9. THEME SETTINGS
   ===================================================== */

.theme-settings {
  display: grid;
  gap: 16px;
}

.color-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid var(--surface);
  outline: 1px solid var(--border);
}

.color-swatch.active {
  outline: 2px solid var(--text);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* =====================================================
   10. RESPONSIVE
   ===================================================== */

@media(max-width:1050px) {
  .grid-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .app { grid-template-columns: 70px minmax(0,1fr); }
  .sidebar { padding: 20px 8px; }
  .brand, .brand-sub, .nav-label { display: none; }
  .nav-item { font-size: 0; text-align: center; }
  .nav-item::first-letter { font-size: 17px; }
}

@media(max-width:650px) {
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  h1 { font-size: 22px; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; }
}
