:root {
  --bg: #0f1117;
  --bg-card: #181b24;
  --bg-hover: #1f2430;
  --border: #2a3040;
  --text: #e8eaef;
  --muted: #8b93a7;
  --accent: #6c8cff;
  --accent-hover: #5a7af5;
  --success: #3dd68c;
  --danger: #f87171;
  --warning: #fbbf24;
  --radius: 10px;
  --sidebar-w: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

.brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
}

.brand-title { font-weight: 600; font-size: 1rem; }
.brand-sub { font-size: 0.75rem; color: var(--muted); }

.nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }

.nav-btn {
  background: none; border: none; color: var(--muted);
  text-align: left; padding: 0.6rem 0.75rem;
  border-radius: 8px; cursor: pointer;
  font-size: 0.9rem; transition: all 0.15s;
}
.nav-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-btn.active { background: rgba(108,140,255,0.15); color: var(--accent); font-weight: 500; }

.sidebar-footer { padding-top: 1rem; border-top: 1px solid var(--border); }

.balance-pill {
  font-size: 0.8rem; color: var(--muted);
  background: var(--bg-hover);
  padding: 0.5rem 0.75rem;
  border-radius: 20px;
  text-align: center;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 1.5rem 2rem;
  max-width: 1200px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.topbar h1 { font-size: 1.5rem; font-weight: 600; }

.panel.hidden { display: none; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card h2 { font-size: 1rem; margin-bottom: 1rem; font-weight: 600; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.card-header h2 { margin-bottom: 0; }

.field { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.field span { font-size: 0.8rem; color: var(--muted); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.checkbox-field { flex-direction: row !important; align-items: center; gap: 0.5rem !important; padding-top: 1.5rem; }

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  width: 100%;
}
textarea { resize: vertical; font-family: inherit; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  border: none; border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem; cursor: pointer;
  transition: background 0.15s;
}
.btn-primary { background: var(--accent); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-danger { color: var(--danger); border-color: var(--danger); }

.hint { font-size: 0.8rem; color: var(--muted); margin-top: 0.75rem; }
.muted { color: var(--muted); font-size: 0.9rem; }

.result-area { min-height: 200px; }
.result-area img, .result-area video {
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 0.75rem;
}
.result-meta { font-size: 0.8rem; color: var(--muted); margin-top: 0.5rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th, td { text-align: left; padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 500; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-ready { background: rgba(61,214,140,0.15); color: var(--success); }
.badge-depleted { background: rgba(251,191,36,0.15); color: var(--warning); }
.badge-disabled { background: rgba(248,113,113,0.15); color: var(--danger); }
.badge-default { background: rgba(108,140,255,0.15); color: var(--accent); }

.toast {
  position: fixed; top: 1rem; right: 1rem;
  padding: 0.75rem 1.25rem;
  border-radius: 8px; font-size: 0.9rem;
  z-index: 1000; max-width: 400px;
  animation: slideIn 0.2s ease;
}
.toast.success { background: #1a3d2e; border: 1px solid var(--success); color: var(--success); }
.toast.error { background: #3d1a1a; border: 1px solid var(--danger); color: var(--danger); }
.toast.hidden { display: none; }

.loading {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 2000;
}
.loading.hidden { display: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loading p { margin-top: 1rem; color: var(--muted); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }
