:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #16213e;
  --border: #2a2a4a;
  --accent: #e94560;
  --accent2: #0f3460;
  --green: #00b894;
  --blue: #74b9ff;
  --gold: #fdcb6e;
  --text: #e0e0e0;
  --muted: #888;
  --radius: 8px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

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

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0f0f1a 70%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 380px;
  text-align: center;
}

.login-logo {
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 3px;
}

.login-sub { color: var(--muted); margin: 8px 0 28px; }

.login-error {
  background: rgba(233,69,96,0.15);
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 10px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.login-card label {
  display: block;
  text-align: left;
  color: var(--muted);
  margin-bottom: 6px;
  font-size: 12px;
}

.login-card input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  margin-bottom: 20px;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-name {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 2px;
}

.brand-sub { font-size: 11px; color: var(--muted); }

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.15s;
  font-size: 13px;
}

.nav-item:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent2); color: var(--text); border-right: 3px solid var(--accent); }
.nav-item.logout { color: var(--accent); }
.nav-icon { font-size: 16px; }

.sidebar-footer { border-top: 1px solid var(--border); padding: 8px 0; }

.content {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-header h1 { font-size: 22px; font-weight: 600; }

.badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--muted);
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-card.accent-green { border-top: 3px solid var(--green); }
.stat-card.accent-blue { border-top: 3px solid var(--blue); }
.stat-card.accent-gold { border-top: 3px solid var(--gold); }

.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

.profit-pos { color: var(--green); }
.profit-neg { color: var(--accent); }

/* Panels */
.panel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.panel h2 { font-size: 15px; margin-bottom: 16px; }

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

.panel-header h2 { margin: 0; }
.link { font-size: 12px; }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border: none; }

.hint { font-size: 12px; color: var(--muted); margin-top: 12px; }
.hint code { background: var(--surface2); padding: 2px 6px; border-radius: 4px; }

/* Tables */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

tbody tr:last-child td { border: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

.empty { text-align: center; color: var(--muted); padding: 24px !important; }

/* Badges */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.tag-green { background: rgba(0,184,148,0.15); color: var(--green); }
.tag-red { background: rgba(233,69,96,0.15); color: var(--accent); }
.tag-gray { background: rgba(136,136,136,0.15); color: var(--muted); }
.tag-blue { background: rgba(116,185,255,0.15); color: var(--blue); }
.tag-gold { background: rgba(253,203,110,0.15); color: var(--gold); }

.status-badge {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.status-ok { background: rgba(0,184,148,0.15); color: var(--green); }
.status-no { background: rgba(233,69,96,0.15); color: var(--accent); }

/* Buttons */
.btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}

.btn:hover { background: var(--accent2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: #ff6b6b; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 12px; }
.btn-danger { color: var(--accent); border-color: var(--accent); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }

.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }

.modal-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  width: 420px;
  z-index: 1;
}

.modal-box h2 { margin-bottom: 20px; font-size: 18px; }
.modal-box label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.modal-box input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  color: var(--text);
  margin-bottom: 16px;
}

.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.key-display {
  display: block;
  background: var(--surface2);
  border: 1px solid var(--green);
  padding: 12px;
  border-radius: var(--radius);
  font-size: 16px;
  letter-spacing: 1px;
  color: var(--green);
  text-align: center;
  margin: 12px 0;
  word-break: break-all;
}

.success-msg { color: var(--green); font-size: 13px; }
.modal-hint { color: var(--muted); font-size: 12px; margin: 0 0 14px; }
.error-msg { color: var(--red, #e94560); font-size: 12px; margin-bottom: 12px; }

/* Weights */
.weight-item { margin-bottom: 12px; }
.weight-label { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; }
.weight-track { background: var(--surface2); border-radius: 4px; height: 8px; overflow: hidden; }
.weight-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }

.mode-list { list-style: none; }
.mode-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.mode-list li:last-child { border: none; }

.download-link-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 12px;
}

.download-link-box code {
  flex: 1;
  font-size: 13px;
  color: var(--green);
  word-break: break-all;
}

.upload-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.upload-form input[type="file"] {
  flex: 1;
  min-width: 200px;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: var(--radius);
  color: var(--text);
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 14px;
}

.alert-ok { background: rgba(0,184,148,0.15); border: 1px solid var(--green); color: var(--green); }
.alert-error { background: rgba(233,69,96,0.15); border: 1px solid var(--accent); color: var(--accent); }

.dir-call { color: var(--green); font-weight: 600; }
.dir-put { color: var(--accent); font-weight: 600; }

@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid, .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .stats-grid { grid-template-columns: 1fr; }
}
