:root {
  --bg: #0b1020;
  --bg-soft: #121931;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-strong: rgba(255, 255, 255, 0.08);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-strong: rgba(255, 255, 255, 0.12);
  --text: #f5f7fb;
  --muted: #96a0bc;
  --primary: #6d7cff;
  --primary-2: #8b5cf6;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 22px;
  --radius-sm: 18px;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at top, #162140, #090d18 55%),
    linear-gradient(180deg, #0b1020 0%, #090d18 100%);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

form {
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  border-right: 1px solid var(--panel-border);
  background: rgba(9, 13, 24, 0.88);
  backdrop-filter: blur(18px);
  padding: 28px 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-sub {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.45;
}

.nav-menu {
  display: grid;
  gap: 10px;
  margin-top: 30px;
}

.nav-link {
  padding: 14px 16px;
  border-radius: 14px;
  color: var(--muted);
  transition:
    background 0.2s ease,
    color 0.2s ease,
    transform 0.2s ease;
}

.nav-link.active,
.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.main-content {
  padding: 34px;
}

/* Header */
.topbar {
  margin-bottom: 26px;
}

.page-title {
  margin: 0;
  font-size: 2.1rem;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

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

/* Dashboard stack */
.dashboard-stack {
  display: grid;
  gap: 24px;
}

.dashboard-stack > .panel,
.dashboard-stack > .grid,
.dashboard-stack > div {
  min-width: 0;
}

/* Grids */
.grid {
  display: grid;
  gap: 24px;
}

.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.three-col {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

.stats-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: stretch;
}

/* Panels */
.panel {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.06),
    rgba(255, 255, 255, 0.04)
  );
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px;
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

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

/* Stat cards */
.stat-card {
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.08),
    rgba(255, 255, 255, 0.04)
  );
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 22px 20px;
  display: grid;
  gap: 12px;
  min-height: 124px;
  box-shadow: var(--shadow-soft);
}

.stat-card span,
.stat-card .muted {
  font-size: 0.98rem;
}

.stat-card strong {
  font-size: 2rem;
  line-height: 1;
  letter-spacing: -0.04em;
}

/* Buttons */
.btn {
  border: 0;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  transition:
    transform 0.18s ease,
    opacity 0.18s ease,
    background 0.18s ease;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 12px 24px rgba(109, 124, 255, 0.22);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--panel-border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-small {
  padding: 0 16px !important;
}

.full {
  width: 100%;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: 16px;
}

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

th,
td {
  padding: 16px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: middle;
}

thead th {
  padding-top: 8px;
}

th {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: 0;
}

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

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(109, 124, 255, 0.18);
  border: 1px solid rgba(109, 124, 255, 0.3);
  font-size: 0.86rem;
  white-space: nowrap;
}

/* Forms */
.form-grid {
  display: grid;
  gap: 18px;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  font-weight: 600;
}

input,
textarea,
select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 14px 15px;
  outline: none;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(139, 92, 246, 0.6);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.12);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

select[multiple] {
  min-height: 180px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

/* Product cards */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

.product-card {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--panel-border);
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
}

.product-image {
  height: 240px;
  width: 100%;
  object-fit: cover;
}

.product-content {
  padding: 18px;
  display: grid;
  gap: 12px;
}

.price-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.price-row.lg strong {
  font-size: 2rem;
}

.old-price {
  color: var(--muted);
  text-decoration: line-through;
}

.promo-note {
  color: #c4b5fd;
  font-size: 0.92rem;
}

/* Store detail */
.store-detail-grid {
  grid-template-columns: 1.15fr 1fr;
}

.product-showcase {
  min-height: 500px;
  display: grid;
  place-items: center;
}

.product-show-image {
  height: 100%;
  width: 100%;
  max-height: 540px;
  object-fit: cover;
  border-radius: 18px;
}

.center-panel {
  max-width: 680px;
  margin: 0 auto;
  text-align: center;
}

.receipt-box {
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  margin: 18px 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* Activity cards */
.stack-cards {
  display: grid;
  gap: 14px;
}

.mini-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 18px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  min-height: 94px;
}

.right-align {
  text-align: right;
  white-space: nowrap;
}

/* Charts */
.chart-list {
  display: grid;
  gap: 12px;
}

.chart-row {
  display: grid;
  grid-template-columns: 120px 1fr 180px;
  gap: 12px;
  align-items: center;
}

.chart-bar-wrap {
  height: 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
}

.chart-bar {
  height: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-radius: 999px;
}

/* Utility spacing */
.mb-0 {
  margin-bottom: 0;
}

.mt-0 {
  margin-top: 0;
}

.center-auth-wrap {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 520px;
  background: linear-gradient(
    180deg,
    rgba(255, 255, 255, 0.07),
    rgba(255, 255, 255, 0.04)
  );
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-card-lg {
  max-width: 620px;
}

.auth-head {
  margin-bottom: 20px;
}

.auth-head h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  letter-spacing: -0.03em;
}

.auth-foot {
  margin-top: 18px;
  text-align: center;
}

.alert-error {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.24);
  color: #fecaca;
}

.app-shell.no-sidebar {
  grid-template-columns: 1fr;
}

.sidebar-user-card {
  margin-top: 24px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: grid;
  gap: 12px;
}

.sidebar-user-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-user-email,
.sidebar-user-company {
  margin: 0;
  word-break: break-word;
}

.form-panel {
  max-width: 980px;
}

.form-subtitle {
  margin: 8px 0 0;
}

.form-grid-lg {
  gap: 24px;
}

.form-section {
  display: grid;
  gap: 20px;
}

.form-section-sm {
  gap: 16px;
}

.field-help {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: -2px;
}

.toggle-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.toggle-card p {
  margin: 6px 0 0;
}

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
}

.switch-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 4px;
}

@media (max-width: 640px) {
  .toggle-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .form-actions .btn {
    width: 100%;
  }
}

.input-with-action {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-action input {
  width: 100%;
  padding-right: 70px;
}

.toggle-password {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: #8b5cf6;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

.toggle-password:hover {
  opacity: 0.8;
}

.input-with-prefix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-prefix input {
  width: 100%;
  padding-left: 42px;
}

.currency-symbol {
  position: absolute;
  left: 14px;
  font-weight: 700;
  color: var(--primary-2);
  pointer-events: none;
}

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

.generated-meta-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--panel-border, rgba(255, 255, 255, 0.08));
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.generated-meta-box p {
  margin: 6px 0 0;
  word-break: break-word;
}

.purchases-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 22px 0 24px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.filter-select {
  min-width: 220px;
  height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid var(--panel-border-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.filter-select:focus {
  border-color: rgba(109, 124, 255, 0.55);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 0 4px rgba(109, 124, 255, 0.12);
}

.filter-select option {
  background: #111827;
  color: #f5f7fb;
}

.purchases-filters .btn {
  min-width: 120px;
  height: 48px;
}

.expand-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition:
    background 0.18s ease,
    transform 0.18s ease,
    border-color 0.18s ease;
}

.expand-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.purchase-detail-row td {
  padding-top: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.purchase-detail-card {
  margin: 0 0 12px;
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: grid;
  gap: 18px;
}

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

.purchase-detail-block {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.purchase-detail-block h3,
.purchase-items-box h3 {
  margin: 0 0 12px;
  font-size: 1rem;
  letter-spacing: -0.02em;
}

.purchase-detail-block p {
  margin: 0 0 8px;
  color: var(--muted);
}

.purchase-detail-block p strong {
  color: var(--text);
}

.purchase-items-box {
  display: grid;
  gap: 12px;
}

.purchase-items-list {
  display: grid;
  gap: 12px;
}

.purchase-item-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.purchase-item-main {
  display: grid;
  gap: 6px;
}

.purchase-item-meta {
  display: grid;
  gap: 6px;
  text-align: right;
  min-width: 220px;
}

.purchase-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* -------------------------------------------------------------- */
@media (max-width: 900px) {
  .purchase-detail-grid {
    grid-template-columns: 1fr;
  }

  .purchase-item-card {
    flex-direction: column;
  }

  .purchase-item-meta {
    min-width: 0;
    text-align: left;
  }
}

@media (max-width: 900px) {
  .purchases-filters {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-select,
  .purchases-filters .btn {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 720px) {
  .generated-meta-box {
    grid-template-columns: 1fr;
  }
}

/* Responsive */
@media (max-width: 1400px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1200px) {
  .product-grid,
  .two-col,
  .three-col,
  .store-detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    padding-bottom: 18px;
  }

  .main-content {
    padding: 20px;
  }

  .stats-grid,
  .product-grid,
  .two-col,
  .three-col,
  .store-detail-grid {
    grid-template-columns: 1fr;
  }

  .chart-row {
    grid-template-columns: 1fr;
  }

  .mini-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .right-align {
    text-align: left;
    white-space: normal;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: 16px;
  }

  .panel {
    padding: 20px;
    border-radius: 18px;
  }

  .stat-card {
    min-height: auto;
    padding: 18px;
  }

  .page-title {
    font-size: 1.8rem;
  }

  .btn {
    width: 100%;
  }

  .inline-actions {
    width: 100%;
  }

  .inline-actions > * {
    flex: 1 1 100%;
  }

  th,
  td {
    padding: 14px 8px;
  }
}
