:root {
  --bg: #f3f4fa;
  --bg-2: #edeff7;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --panel-dark: #141320;
  --line: rgba(82, 69, 140, 0.12);
  --line-strong: rgba(82, 69, 140, 0.18);
  --text: #1a1730;
  --muted: #746f8e;
  --accent: #7b2ff7;
  --accent-2: #9f53ff;
  --accent-3: #6c2be2;
  --accent-soft: rgba(123, 47, 247, 0.1);
  --success: #13b67a;
  --warning: #e5a500;
  --danger: #e45b78;
  --sidebar-bg: linear-gradient(180deg, #0d0c16 0%, #141324 100%);
  --sidebar-line: rgba(255, 255, 255, 0.08);
  --sidebar-text: #f5f2ff;
  --shadow: 0 20px 40px rgba(25, 16, 52, 0.08);
  --shadow-soft: 0 10px 26px rgba(25, 16, 52, 0.05);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family:
    Inter,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    sans-serif;
  background:
    radial-gradient(
      circle at top left,
      rgba(123, 47, 247, 0.05),
      transparent 28%
    ),
    radial-gradient(
      circle at top right,
      rgba(164, 76, 255, 0.04),
      transparent 24%
    ),
    var(--bg);
  color: var(--text);
  scroll-behavior: smooth;
}

a {
  text-decoration: none;
  color: inherit;
}

button,
input,
select {
  font: inherit;
}

html {
  font-size: 15px;
}

body {
  line-height: 1.4;
}

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-line);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  align-self: flex-start;
  overflow: auto;
  color: var(--sidebar-text);
  box-shadow: 18px 0 44px rgba(12, 9, 24, 0.14);
  z-index: 10;
}

.sidebar__top {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: auto;
}

.main {
  flex: 1;
  padding: 16px 18px;
  min-width: 0;
}

.main--auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 2px;
}

.brand__logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
  box-shadow: 0 16px 34px rgba(123, 47, 247, 0.35);
  flex: 0 0 auto;
}

.brand__title {
  font-size: 15px;
  font-weight: 800;
}

.brand__subtitle {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.62);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav__link {
  padding: 11px 13px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--sidebar-text);
  transition:
    background 0.18s ease,
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
}

.nav__link:hover {
  background: rgba(123, 47, 247, 0.16);
  border-color: rgba(164, 76, 255, 0.35);
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(164, 76, 255, 0.08);
}

.userbox {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.userbox__name {
  font-weight: 700;
}

.userbox__meta {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.62);
  margin-top: 4px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.page-header__main {
  min-width: 0;
  flex: 1;
}

.page-header__title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.page-header h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.06;
  letter-spacing: -0.02em;
}

.muted {
  color: var(--muted);
}

.toolbar {
  display: flex;
  gap: 10px;
}

.toolbar--top {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.stats-compact {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stats-compact--tight .stat-mini {
  min-height: 84px;
}

.stat-mini {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), #ffffff);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.stat-mini::after {
  content: "";
  position: absolute;
  inset: auto auto 0 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    rgba(123, 47, 247, 0.22),
    rgba(164, 76, 255, 0)
  );
}

.stat-mini__label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-mini__value {
  font-size: 24px;
  font-weight: 800;
  color: #24193f;
  letter-spacing: -0.02em;
}

.grid-two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.grid-two--settings {
  align-items: start;
}

.dashboard-lower-grid {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.dashboard-lower-grid__left,
.dashboard-lower-grid__right {
  min-width: 0;
}

.card {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  position: relative;
}

.card--compact {
  padding: 14px 16px;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}

.card__header--tight {
  margin-bottom: 10px;
}

.card__header h2 {
  margin: 0;
  font-size: 18px;
  color: #221b42;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.table-meta {
  font-size: 13px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form--inline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  align-items: end;
}

.form--compact {
  gap: 8px;
}

.form--filters {
  grid-template-columns: 1.45fr 1fr 1fr 1.15fr 0.8fr;
  margin-bottom: 10px;
}

.form--settings {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field span {
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  outline: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    transform 0.18s ease;
}

.field input:focus,
.field select:focus {
  border-color: rgba(123, 47, 247, 0.45);
  box-shadow: 0 0 0 4px rgba(123, 47, 247, 0.08);
  transform: translateY(-1px);
}

.field--grow {
  grid-column: span 3;
}

.btn {
  border: none;
  border-radius: 13px;
  padding: 10px 14px;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    opacity 0.18s ease,
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease;
  white-space: nowrap;
  font-weight: 600;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn--primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 16px 28px rgba(123, 47, 247, 0.2);
}

.btn--primary:hover {
  box-shadow: 0 18px 30px rgba(123, 47, 247, 0.24);
}

.btn--secondary {
  background: linear-gradient(180deg, #f6f2ff, #f1edfb);
  color: #2f2354;
  border: 1px solid rgba(123, 47, 247, 0.14);
  box-shadow: inset 0 0 0 1px rgba(123, 47, 247, 0.03);
}

.btn--ghost {
  background: transparent;
  color: var(--sidebar-text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn--danger {
  background: rgba(228, 91, 120, 0.08);
  color: #b02d50;
  border: 1px solid rgba(228, 91, 120, 0.2);
}

.btn--block {
  width: 100%;
}

.btn--small {
  padding: 8px 11px;
  font-size: 12px;
}

.alert {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  margin-bottom: 16px;
}

.alert--error {
  background: rgba(228, 91, 120, 0.08);
  border: 1px solid rgba(228, 91, 120, 0.2);
  color: #b02d50;
}

.table-wrap,
.users-list__table-wrap {
  overflow: auto;
}

.table-wrap--compact {
  border: 1px solid rgba(60, 50, 110, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.table--dense th,
.table--dense td {
  padding: 11px 10px;
}

.table th,
.table td {
  text-align: left;
  border-bottom: 1px solid rgba(60, 50, 110, 0.07);
  vertical-align: top;
}

.table th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  background: rgba(248, 246, 253, 0.75);
}

.table tbody tr {
  transition: background 0.18s ease;
}

.table tbody tr:hover {
  background: rgba(123, 47, 247, 0.035);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.01em;
}

.badge--success {
  background: rgba(19, 182, 122, 0.1);
  color: #0c8b5c;
  border: 1px solid rgba(19, 182, 122, 0.18);
}

.badge--warning {
  background: rgba(229, 165, 0, 0.12);
  color: #8a6500;
  border: 1px solid rgba(229, 165, 0, 0.18);
}

.badge--muted {
  background: #f3f0fa;
  color: #6b618a;
  border: 1px solid rgba(60, 50, 110, 0.08);
}

.badges-inline {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.message-line {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

.message-line--ok {
  color: #0c8b5c;
}

.message-line--error {
  color: #b02d50;
}

.plain-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.plain-list--compact {
  gap: 6px;
  font-size: 13px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toggle-row--compact {
  min-height: 100%;
}

.toggle-row__title {
  font-weight: 700;
  margin-bottom: 4px;
}

.toggle-row__text {
  color: var(--muted);
  font-size: 13px;
  max-width: 640px;
}

.switch {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 32px;
  flex: 0 0 auto;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #e7e1f6;
  border: 1px solid rgba(123, 47, 247, 0.12);
  border-radius: 999px;
  transition: 0.2s;
}

.switch__slider:before {
  content: "";
  position: absolute;
  height: 24px;
  width: 24px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 4px 10px rgba(20, 12, 44, 0.12);
}

.switch input:checked + .switch__slider {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

.switch input:checked + .switch__slider:before {
  transform: translateX(24px);
}

.auth {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.auth-card__header {
  margin-bottom: 20px;
}

.auth-card__header h1 {
  margin: 0 0 8px 0;
}

.auth-card__header p {
  margin: 0;
  color: var(--muted);
}

.live-meta {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
}

.live-meta__row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.live-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #c7bfdc;
  display: inline-block;
}

.live-dot.is-loading {
  background: #e5a500;
  box-shadow: 0 0 0 6px rgba(229, 165, 0, 0.12);
}

.live-dot.is-ok {
  background: #13b67a;
  box-shadow: 0 0 0 6px rgba(19, 182, 122, 0.12);
}

.live-dot.is-error {
  background: #e45b78;
  box-shadow: 0 0 0 6px rgba(228, 91, 120, 0.12);
}

.separator {
  color: #b1abc5;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill--ok {
  background: rgba(19, 182, 122, 0.1);
  color: #0c8b5c;
  border: 1px solid rgba(19, 182, 122, 0.18);
}

.status-pill--error {
  background: rgba(228, 91, 120, 0.08);
  color: #b02d50;
  border: 1px solid rgba(228, 91, 120, 0.18);
}

.status-strip__message {
  color: var(--muted);
  font-size: 13px;
}

.hint-line {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.freshness-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.freshness-badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 auto;
}

.freshness-badge__counter {
  min-width: 20px;
  text-align: center;
}

.freshness-badge--fresh {
  background: rgba(19, 182, 122, 0.1);
  color: #0c8b5c;
  border: 1px solid rgba(19, 182, 122, 0.18);
  box-shadow: 0 0 0 4px rgba(19, 182, 122, 0.05);
}

.freshness-badge--fresh .freshness-badge__dot {
  background: #13b67a;
}

.freshness-badge--warn {
  background: rgba(229, 165, 0, 0.12);
  color: #8a6500;
  border: 1px solid rgba(229, 165, 0, 0.18);
  box-shadow: 0 0 0 4px rgba(229, 165, 0, 0.05);
}

.freshness-badge--warn .freshness-badge__dot {
  background: #e5a500;
}

.freshness-badge--stale {
  background: rgba(228, 91, 120, 0.08);
  color: #b02d50;
  border: 1px solid rgba(228, 91, 120, 0.18);
  box-shadow: 0 0 0 4px rgba(228, 91, 120, 0.05);
}

.freshness-badge--stale .freshness-badge__dot {
  background: #e45b78;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.pagination__meta {
  font-size: 13px;
  color: var(--muted);
}

.warehouse-add-form {
  position: relative;
}

.warehouse-add-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.warehouse-selected {
  margin: 0;
  flex: 1;
  min-width: 220px;
}

.warehouse-hints {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(60, 50, 110, 0.08);
}

.wb-search-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  margin-top: 4px;
  padding-right: 2px;
}

.wb-search-state {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(123, 47, 247, 0.04);
  border: 1px dashed rgba(123, 47, 247, 0.14);
}

.wb-search-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  text-align: left;
  border: 1px solid rgba(60, 50, 110, 0.1);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}

.wb-search-item:hover {
  background: rgba(123, 47, 247, 0.04);
  border-color: rgba(123, 47, 247, 0.24);
  transform: translateY(-1px);
  box-shadow: 0 10px 18px rgba(123, 47, 247, 0.08);
}

.access-form--grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr 0.9fr;
  gap: 10px;
  align-items: end;
}

.access-form__submit {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.global-refresh-overlay {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  pointer-events: none;
}

.global-refresh-overlay__inner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 14px;
  background: rgba(18, 15, 31, 0.92);
  color: #fff;
  box-shadow: 0 18px 40px rgba(15, 12, 28, 0.28);
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(14px);
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.75s linear infinite;
}

.dashboard-refresh-target {
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.25s ease,
    border-color 0.25s ease;
}

.dashboard-refresh-target.is-refreshing {
  opacity: 0.72;
  transform: translateY(1px);
  position: relative;
}

.dashboard-refresh-target.is-refreshing::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(123, 47, 247, 0.06) 45%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  pointer-events: none;
}

.dashboard-refresh-target.is-updated-flash {
  border-color: rgba(123, 47, 247, 0.3);
  box-shadow:
    0 0 0 3px rgba(123, 47, 247, 0.06),
    var(--shadow);
}

@keyframes shimmer {
  from {
    background-position: 200% 0;
  }
  to {
    background-position: -200% 0;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1380px) {
  .dashboard-lower-grid {
    grid-template-columns: 360px minmax(0, 1fr);
  }

  .form--filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1220px) {
  .dashboard-lower-grid {
    grid-template-columns: 1fr;
  }

  .access-form--grid {
    grid-template-columns: 1fr;
  }

  .access-form__submit {
    justify-content: flex-start;
  }
}

@media (max-width: 1100px) {
  .stats-compact {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-two {
    grid-template-columns: 1fr;
  }

  .form--inline,
  .form--filters,
  .form--settings {
    grid-template-columns: 1fr;
  }

  .field--grow {
    grid-column: auto;
  }
}

@media (max-width: 860px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    width: auto;
    height: auto;
    position: relative;
    top: auto;
    padding: 14px;
  }

  .sidebar__top,
  .sidebar__footer {
    gap: 12px;
  }

  .main {
    padding: 14px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar--top {
    justify-content: flex-start;
  }

  .stats-compact {
    grid-template-columns: 1fr;
  }

  .toggle-row,
  .toggle-row--compact {
    flex-direction: column;
    align-items: flex-start;
  }

  .warehouse-add-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .warehouse-selected {
    min-width: 0;
  }

  .global-refresh-overlay {
    right: 12px;
    left: 12px;
    bottom: 12px;
  }

  .global-refresh-overlay__inner {
    width: 100%;
    justify-content: center;
  }
}
