:root {
  --bg: #0f1117;
  --bg-2: #171a24;
  --card: #1e2230;
  --line: #2a2f40;
  --text: #e7e9f0;
  --muted: #8b91a7;
  --accent: #7c3aed;
  --accent-2: #a78bfa;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  padding-bottom: 74px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(15, 17, 23, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand { font-size: 1.3rem; font-weight: 800; letter-spacing: 0.5px; }
.brand span { color: var(--accent-2); }

.chip { color: var(--muted); font-size: 0.85rem; margin-right: 8px; }

.container { max-width: 640px; margin: 0 auto; padding: 16px; }

h1 { font-size: 1.3rem; margin-bottom: 12px; }
h2 { font-size: 1.05rem; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 0.85rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

input, select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  margin-bottom: 10px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }

label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.ok { background: var(--ok); color: #0f1117; }
.btn.small { padding: 6px 10px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.card-mini {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card-mini img { width: 100%; aspect-ratio: 63/88; object-fit: cover; background: var(--bg-2); }
.card-mini .info { padding: 8px; }
.card-mini .name { font-size: 0.82rem; font-weight: 700; margin-bottom: 4px; }
.card-mini .actions { display: flex; gap: 6px; padding: 0 8px 8px; flex-wrap: wrap; }

.pill {
  display: inline-block;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.75rem;
}

.pill.accent { color: var(--accent-2); border-color: var(--accent); }
.pill.ok { color: var(--ok); border-color: var(--ok); }
.pill.warn { color: var(--warn); border-color: var(--warn); }
.pill.danger { color: var(--danger); border-color: var(--danger); }

.price { color: var(--ok); font-weight: 700; }

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  justify-content: space-around;
  background: rgba(15, 17, 23, 0.97);
  border-top: 1px solid var(--line);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
}

.nav-item {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.72rem;
  padding: 4px 6px;
  cursor: pointer;
}
.nav-item.active { color: var(--accent-2); font-weight: 700; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  width: 100%;
  max-width: 640px;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  max-height: 85vh;
  overflow-y: auto;
}

.chat { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow-y: auto; }
.msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; font-size: 0.9rem; background: var(--bg); }
.msg.mine { align-self: flex-end; background: var(--accent); color: #fff; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
}

.toast {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 60;
  animation: fade 2.5s forwards;
}
@keyframes fade {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  10% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 30px auto;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.metric { font-size: 1.8rem; font-weight: 800; color: var(--accent-2); }

.section-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; }
.section-tabs button {
  flex: 0 0 auto;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
}
.section-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
