:root {
  --bg: #07070c;
  --bg2: #0e0e18;
  --panel: #12121f;
  --line: #24243a;
  --text: #e8ecff;
  --muted: #8b93b0;
  --accent: #00d4ff;
  --accent-dim: rgba(0, 212, 255, 0.14);
  --buy: #3b82f6;
  --sell: #eab308;
  --ok: #22c55e;
  --danger: #ef4444;
  --radius: 14px;
  --font: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 8% -10%, #152238 0%, transparent 55%),
    radial-gradient(700px 380px at 100% 0%, #1a1520 0%, transparent 50%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; }

.wrap {
  width: min(1100px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.brand {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0;
}
.brand span { color: var(--accent); }
.sub {
  color: var(--muted);
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.45;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.login-card label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 14px 0 6px;
}
.login-card input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 12px 12px;
}
.login-card button {
  width: 100%;
  margin-top: 18px;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  background: var(--accent);
  color: #041018;
  font-weight: 700;
  cursor: pointer;
}
.err {
  color: var(--danger);
  font-size: 13px;
  min-height: 1.2em;
  margin-top: 10px;
}

.topbar {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 650;
  cursor: pointer;
  font-size: 13px;
}
.btn-primary { background: var(--accent); color: #041018; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-danger {
  background: #3a1520;
  color: #fecaca;
  border: 1px solid #7f1d1d;
}

.grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
}
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
}

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tab.active {
  color: #041018;
  background: var(--accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.field {
  margin-bottom: 10px;
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 11px;
}
.field textarea {
  min-height: 72px;
  resize: vertical;
}
.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 560px) {
  .row2 { grid-template-columns: 1fr; }
}

.levels {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.level {
  display: grid;
  grid-template-columns: 1fr 88px 88px auto;
  gap: 8px;
  align-items: end;
}
@media (max-width: 560px) {
  .level { grid-template-columns: 1fr 1fr; }
  .level .level-remove { grid-column: 1 / -1; }
}
.level-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.level-field label {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.2;
}
.level input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 10px;
}
.level .btn {
  height: 38px;
  align-self: end;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  margin-bottom: 4px;
}
.section-head strong { font-size: 14px; }
.section-head.buy strong { color: #93c5fd; }
.section-head.sell strong { color: #fde68a; }

.clients-hint {
  margin: 0 0 12px;
  font-size: 12px;
}
.clients-table-wrap {
  overflow-x: auto;
  max-height: 240px;
  overflow-y: auto;
}
.clients-table-wrap--full {
  max-height: min(70vh, 640px);
}
.clients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.clients-table th,
.clients-table td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}
.clients-table th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}
.clients-table td.account { font-family: var(--mono); color: var(--accent); }
.clients-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.clients-table input.note-input {
  width: min(180px, 100%);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 6px 8px;
}
.clients-table .vip-row td { background: rgba(0, 212, 255, 0.06); }
.clients-empty { color: var(--muted); font-size: 13px; padding: 8px 0; }

.hist-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s ease;
}
.hist-item:hover { border-color: #3a3a58; }
.hist-item strong { display: block; font-size: 14px; }
.hist-item span { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-dim);
  color: var(--accent);
  margin-left: 6px;
}
.badge.cleared { background: #2a1a1a; color: #fca5a5; }

.status {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  min-height: 1.2em;
}
.status.ok { color: var(--ok); }
.status.err { color: var(--danger); }

.preview {
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  min-height: 120px;
  color: #b7f3ff;
}

.hidden { display: none !important; }
