:root {
  --bg: #090b10;
  --panel: #121722;
  --panel-2: #1a2130;
  --panel-3: #202a3d;
  --border: #2a344a;
  --text: #f5f7fb;
  --muted: #a9b2c3;
  --soft: #748199;
  --purple: #7c5cff;
  --purple-2: #9f8bff;
  --green: #24d27e;
  --green-dark: #0e3d2c;
  --yellow: #ffbd4a;
  --red: #ff5d73;
  --blue: #52a8ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: radial-gradient(circle at top left, rgba(124,92,255,.16), transparent 34rem), var(--bg);
  color: var(--text);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}
.sidebar {
  background: rgba(15, 20, 31, .94);
  border-right: 1px solid var(--border);
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #7c5cff, #24d27e);
  font-weight: 950;
  color: #fff;
}
.brand strong { display: block; font-size: 18px; }
.brand small { color: var(--muted); font-weight: 700; }
.nav {
  display: grid;
  gap: 8px;
}
.nav button {
  border: 0;
  color: var(--muted);
  background: transparent;
  padding: 12px 14px;
  border-radius: 10px;
  text-align: left;
  font-weight: 800;
}
.nav button.active,
.nav button:hover {
  background: var(--panel-2);
  color: var(--text);
}
.main {
  padding: 32px;
  min-width: 0;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}
.topbar h1 {
  margin: 0 0 4px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
}
.topbar p { margin: 0; color: var(--muted); font-size: 18px; }
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  font-weight: 850;
  white-space: nowrap;
}
.grid {
  display: grid;
  gap: 16px;
}
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.panel,
.card {
  background: rgba(18, 23, 34, .92);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset;
}
.panel h2,
.card h3 {
  margin: 0 0 10px;
}
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.money { color: var(--green); font-weight: 950; }
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.between {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 11px 14px;
  border-radius: 10px;
  font-weight: 900;
}
.btn:hover { filter: brightness(1.08); }
.btn.primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--purple), #694cff);
}
.btn.green {
  border-color: transparent;
  background: var(--green);
  color: #04120b;
}
.btn.ghost { background: transparent; }
.btn.danger {
  background: rgba(255, 93, 115, .14);
  border-color: rgba(255, 93, 115, .4);
  color: #ffdbe1;
}
.btn.small {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--panel-3);
  color: var(--muted);
  font-weight: 900;
  font-size: 12px;
}
.pill.green { color: #35e790; background: rgba(36,210,126,.13); }
.pill.yellow { color: #ffd18a; background: rgba(255,189,74,.14); }
.pill.red { color: #ff9cab; background: rgba(255,93,115,.14); }
.pill.blue { color: #9ed0ff; background: rgba(82,168,255,.14); }
.form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.form .full { grid-column: 1 / -1; }
label { display: grid; gap: 7px; color: var(--muted); font-weight: 850; }
input, select, textarea {
  width: 100%;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 13px;
  outline: none;
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--purple-2); }
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}
th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.62);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 30;
}
.modal-bg.show { display: flex; }
.modal {
  width: min(980px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal h2 { margin-top: 0; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(520px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: 0 0 8px; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 15px;
  box-shadow: var(--shadow);
  z-index: 50;
}
.ai-box {
  background: linear-gradient(135deg, rgba(124,92,255,.16), rgba(36,210,126,.08));
  border: 1px solid rgba(124,92,255,.45);
  border-radius: 14px;
  padding: 18px;
}
.chat-answer {
  white-space: pre-wrap;
  line-height: 1.55;
  background: #0d111a;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.health-card.green { border-color: rgba(36,210,126,.5); }
.health-card.yellow { border-color: rgba(255,189,74,.55); }
.health-card.red { border-color: rgba(255,93,115,.55); }
.setup-list {
  margin: 10px 0 0;
  padding-left: 24px;
  color: var(--muted);
  line-height: 1.7;
}
.item-editor {
  display: grid;
  gap: 10px;
}
.item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) minmax(80px, .5fr) minmax(120px, .7fr) 40px;
  gap: 8px;
  align-items: end;
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 20px; }
  .grid.two, .grid.three, .grid.four, .form { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
}
