:root {
  --bg-0: #04131d;
  --bg-1: #072334;
  --bg-2: #0b2f45;
  --card: linear-gradient(180deg, rgba(8, 29, 44, 0.94), rgba(7, 22, 34, 0.96));
  --line: rgba(77, 189, 167, 0.26);
  --line-soft: rgba(111, 162, 182, 0.2);
  --text: #ecf7ff;
  --muted: #8eb0c3;
  --accent: #25d19b;
  --accent-2: #1bc7e7;
  --danger: #e35d72;
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Sora", "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(1100px 560px at 10% 0%, #0a3e4f 0%, transparent 62%),
              radial-gradient(900px 600px at 100% 0%, #0a304f 0%, transparent 58%),
              linear-gradient(140deg, var(--bg-0), var(--bg-1) 42%, var(--bg-2));
}

.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(closest-side at 28% 14%, rgba(36, 209, 155, 0.12), transparent 72%),
              radial-gradient(closest-side at 76% 10%, rgba(27, 199, 231, 0.1), transparent 68%);
  z-index: -1;
}

.app {
  width: min(1320px, 100%);
  margin: 28px auto 44px;
  padding: 0 20px;
}

#dashboardView > section,
#dashboardView > header {
  margin-top: 16px;
}

.card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.login-card {
  margin: 96px auto 0;
  width: min(620px, 100%);
  text-align: center;
  padding: 34px 28px;
}

.login-kicker {
  margin: 0 0 10px;
  color: #7fe8cb;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.login-card h1 {
  margin: 0 0 10px;
  font-size: clamp(1.65rem, 3vw, 2.25rem);
}

.login-card p {
  margin: 0 auto 18px;
  max-width: 46ch;
  color: var(--muted);
  line-height: 1.45;
}

h2, h3 {
  margin: 0 0 10px;
  letter-spacing: 0.01em;
}

.muted {
  margin: 0;
  color: var(--muted);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.profile {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(148, 201, 220, 0.35);
  background: #173243;
  box-shadow: 0 0 0 4px rgba(37, 209, 155, 0.08);
}

.nav-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.tab-pill {
  border: 1px solid var(--line-soft);
  background: rgba(8, 33, 48, 0.78);
  color: #b8d9e8;
  border-radius: 11px;
  min-height: 42px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.tab-emoji {
  font-size: 0.95rem;
}

.tab-pill-active {
  border-color: transparent;
  color: #043326;
  background: linear-gradient(90deg, #1ed99c, #19b6ce);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  padding: 20px 18px;
}

.stat span {
  color: var(--muted);
  font-size: 0.87rem;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.45rem, 2.2vw, 1.95rem);
}

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.toolbar-info p {
  margin: 0;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inventory-toolbar {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 10px;
  margin-bottom: 14px;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.product-card {
  border: 1px solid rgba(37, 209, 155, 0.28);
  background: linear-gradient(160deg, rgba(7, 38, 52, 0.9), rgba(5, 27, 41, 0.9));
  border-radius: 16px;
  padding: 14px;
}

.product-card-critical {
  border-color: rgba(227, 93, 114, 0.45);
}

.product-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.product-icon {
  margin-left: auto;
  width: 42px;
  height: 42px;
  border-radius: 11px;
  border: 1px solid rgba(85, 186, 165, 0.45);
  background: linear-gradient(160deg, rgba(24, 74, 88, 0.72), rgba(17, 53, 69, 0.74));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #c2f5e6;
  font-weight: 700;
  font-size: 0.95rem;
  overflow: hidden;
}

.product-icon img {
  width: 30px;
  height: 30px;
  image-rendering: pixelated;
}

.product-emoji {
  display: none;
  font-size: 1.15rem;
  line-height: 1;
}

.product-icon.product-icon-fallback .product-emoji {
  display: inline;
}

.product-icon.product-icon-fallback img {
  display: none !important;
}

.product-title-wrap h4 {
  margin: 0;
  max-width: 170px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-sub {
  margin: 4px 0 0;
  color: #8fb7cc;
  font-size: 0.78rem;
}

.product-meta {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.product-tag {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.74rem;
  color: #c8deea;
  background: rgba(76, 112, 133, 0.3);
}

.product-progress {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.bars {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(110px, 1.4fr) minmax(0, 2.7fr) auto;
  gap: 10px;
  align-items: center;
}

.bar-label {
  color: #b8d0de;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: rgba(95, 133, 157, 0.28);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.bar-value {
  font-size: 0.82rem;
  color: #d4eaf5;
}

.auto-deposit-card p {
  margin: 0 0 8px;
}

.stack { display: flex; flex-direction: column; gap: 10px; }
.split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.86rem;
  color: var(--muted);
}

input, select, textarea, button {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 10px 12px;
  background: rgba(8, 29, 44, 0.8);
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: rgba(36, 209, 155, 0.6);
  box-shadow: 0 0 0 2px rgba(36, 209, 155, 0.16);
}

.btn {
  cursor: pointer;
  border-radius: 10px;
  font-weight: 700;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.04);
}

.btn-primary {
  border-color: transparent;
  color: #012317;
  background: linear-gradient(90deg, #2be4a8, #22c8d8);
  box-shadow: 0 8px 24px rgba(43, 228, 168, 0.28);
}

.btn-discord {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 220px;
  min-height: 46px;
  border-color: transparent;
  color: #eff2ff;
  background: linear-gradient(90deg, #5865f2, #7b84ff);
  box-shadow: 0 12px 28px rgba(88, 101, 242, 0.34);
}

.btn-danger {
  border-color: transparent;
  background: linear-gradient(90deg, #e66478, #d34b63);
  color: #fff;
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
}

.table-wrap { overflow: auto; }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(112, 152, 171, 0.18);
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  background: rgba(8, 29, 44, 0.95);
  z-index: 1;
}

th {
  color: #a6c5d6;
  font-size: 0.83rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:hover {
  background: rgba(37, 209, 155, 0.06);
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.73rem;
  font-weight: 700;
}

.badge-ok {
  background: rgba(37, 209, 155, 0.18);
  color: #73f3cf;
}

.badge-critical {
  background: rgba(227, 93, 114, 0.2);
  color: #ff9eb0;
}

.badge-warn {
  background: rgba(255, 184, 77, 0.2);
  color: #ffe1a8;
}

.progress {
  width: 180px;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(95, 133, 157, 0.28);
}

.progress > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.pager {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 9, 16, 0.7);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(520px, 100%);
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(8, 29, 44, 0.94);
  padding: 10px 14px;
  box-shadow: var(--shadow);
  z-index: 70;
}

.hidden { display: none !important; }

@media (max-width: 1160px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: flex-start; }
  .nav-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .products-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inventory-toolbar { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app { padding: 0 12px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .progress { width: 120px; }
  .products-grid { grid-template-columns: 1fr; }
}
