:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3248;
  --accent: #4f7cff;
  --accent2: #7c5cfc;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --text: #e2e8f0;
  --text-muted: #7e8ca0;
  --profit-pos: #22c55e;
  --profit-neg: #ef4444;
  --radius: 8px;
  --font: 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.5; }

/* ── Navbar ─────────────────────────────────────────────────────────────── */
.navbar {
  display: flex; align-items: center; gap: 32px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 52px; position: sticky; top: 0; z-index: 100;
}
.nav-brand { font-size: 16px; font-weight: 700; color: var(--accent); text-decoration: none; white-space: nowrap; }
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a { color: var(--text-muted); text-decoration: none; padding: 6px 12px; border-radius: var(--radius); transition: background .15s, color .15s; }
.nav-links a:hover, .nav-links a.active { background: var(--surface2); color: var(--text); }

.dropdown { position: relative; }
.dropbtn { color: var(--text-muted); padding: 6px 12px; cursor: pointer; border-radius: var(--radius); transition: background .15s, color .15s; }
.dropbtn:hover { background: var(--surface2); color: var(--text); }
.dropdown-content {
  display: none; position: absolute; top: 100%; left: 0; min-width: 180px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.5); z-index: 200; overflow: hidden;
}
.dropdown:hover .dropdown-content { display: block; }
.dropdown-content a { display: block; padding: 10px 16px; color: var(--text-muted); text-decoration: none; transition: background .12s; }
.dropdown-content a:hover { background: var(--surface2); color: var(--text); }

/* ── Container ──────────────────────────────────────────────────────────── */
.container { max-width: 1400px; margin: 0 auto; padding: 24px 20px; }

/* ── Page header ────────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.alert-success { background: rgba(34,197,94,.15); border: 1px solid rgba(34,197,94,.3); color: #86efac; }
.alert-warning { background: rgba(245,158,11,.15); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }
.alert-danger  { background: rgba(239,68,68,.15);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius); border: none; cursor: pointer; font-size: 13px; font-weight: 500; text-decoration: none; transition: opacity .15s, transform .1s; white-space: nowrap; }
.btn:hover { opacity: .85; }
.btn:active { transform: scale(.97); }
.btn-primary  { background: var(--accent);   color: #fff; }
.btn-success  { background: var(--success);  color: #fff; }
.btn-secondary{ background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-outline  { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-outline:hover { color: var(--text); border-color: var(--accent); }

.btn-sm { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 6px; border: none; cursor: pointer; font-size: 12px; font-weight: 500; text-decoration: none; }
.btn-edit { background: rgba(79,124,255,.15); color: var(--accent); }
.btn-edit:hover { background: rgba(79,124,255,.3); }
.btn-del  { background: rgba(239,68,68,.12); color: var(--danger); }
.btn-del:hover  { background: rgba(239,68,68,.25); }

/* ── Form controls ──────────────────────────────────────────────────────── */
.form-control {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius); padding: 8px 12px; font-size: 13px; font-family: var(--font);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--accent); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; }

.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }

.inline-add-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.inline-add-form .form-control { flex: 1; min-width: 200px; }

.edit-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .4px; }
.form-group-wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.form-preview {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; font-size: 14px;
}

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-top: 24px; overflow-x: auto; }
.table-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: var(--surface2); color: var(--text-muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 9px 12px; border-bottom: 1px solid rgba(46,50,72,.6); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(79,124,255,.04); }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table td.actions { white-space: nowrap; text-align: right; }

.profit-pos { color: var(--profit-pos); font-weight: 600; }
.profit-neg { color: var(--profit-neg); font-weight: 600; }

/* ── Pagination ─────────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; color: var(--text-muted); font-size: 13px; }

/* ── Dashboard ──────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 24px; }
.kpi-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.profit-card { border-color: rgba(79,124,255,.4); background: rgba(79,124,255,.06); }
.kpi-value { font-size: 24px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-top: 4px; }

.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 16px; margin-bottom: 24px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.chart-card h3 { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 16px; }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
