:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

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

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #0f172a 100%);
}

.auth-bg-warehouse {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.28;
  pointer-events: none;
  z-index: 0;
}

.auth-card-split {
  position: relative;
  z-index: 1;
  background: var(--surface);
  width: 100%;
  max-width: 410px;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
  animation: cardFadeUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes cardFadeUp {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-banner {
  position: relative;
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 65%, #4338ca 100%);
  color: #ffffff;
  padding: 1.6rem 1.5rem 0;
  text-align: center;
  overflow: hidden;
}

.auth-banner h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: 0.25rem;
  position: relative;
  z-index: 2;
}

.auth-banner p {
  font-size: 0.78rem;
  color: #c7d2fe;
  max-width: 290px;
  margin: 0 auto 0.6rem;
  position: relative;
  z-index: 2;
}

.auth-banner-svg {
  display: block;
  width: 100%;
  height: 125px;
  margin-top: 0.25rem;
}

.auth-body {
  padding: 1.6rem 2rem 1.75rem;
  background: var(--surface);
  text-align: center;
}

.auth-pill-title {
  display: inline-block;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.45rem 1.6rem;
  border-radius: 999px;
  margin-bottom: 1.15rem;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.pill-input-wrap {
  display: flex;
  align-items: center;
  background: var(--primary-soft);
  border: 1.5px solid #c7d2fe;
  border-radius: 999px;
  padding: 0.35rem 0.9rem 0.35rem 0.45rem;
  margin-bottom: 0.85rem;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.pill-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.16);
  transform: translateY(-1px);
}

.pill-input-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  margin-right: 0.6rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.pill-input-wrap input {
  border: none;
  background: transparent;
  outline: none;
  width: 100%;
  font-size: 0.88rem;
  color: var(--text);
}

.pill-input-wrap input::placeholder {
  color: #6366f1;
  opacity: 0.7;
}

.btn-login-animated {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 2.1rem;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #ffffff;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.38);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease, background 0.25s ease;
}

.btn-login-animated::before {
  content: '';
  position: absolute;
  top: 0;
  left: -120%;
  width: 70%;
  height: 100%;
  background: linear-gradient(
    120deg,
    transparent 0%,
    rgba(255, 255, 255, 0.38) 50%,
    transparent 100%
  );
  transform: skewX(-20deg);
  transition: left 0.6s ease;
}

.btn-login-animated:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 12px 28px rgba(79, 70, 229, 0.52);
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

.btn-login-animated:hover:not(:disabled)::before {
  left: 150%;
}

.btn-login-animated:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.btn-login-animated:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.demo-box {
  background: var(--primary-soft);
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  padding: 0.55rem 0.85rem;
  font-size: 0.78rem;
  color: #3730a3;
  margin-bottom: 1rem;
  text-align: center;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: relative;
  width: 250px;
  background: #0f172a;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.9rem;
  flex-shrink: 0;
  transition: width 0.28s cubic-bezier(0.22, 1, 0.36, 1), padding 0.28s ease;
  border-right: 1px solid #1e293b;
  z-index: 30;
}

.sidebar.collapsed {
  width: 76px;
  padding: 1.25rem 0.65rem;
}

.sidebar-toggle-btn {
  position: absolute;
  top: 22px;
  right: -13px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  border: 2px solid #0f172a;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
  transition: transform 0.2s ease, background 0.2s ease;
  z-index: 35;
}

.sidebar-toggle-btn:hover {
  background: var(--primary-hover);
  transform: scale(1.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.5rem 1.25rem;
  border-bottom: 1px solid #1e293b;
  margin-bottom: 1rem;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-logo {
  justify-content: center;
  padding: 0.35rem 0 1.25rem;
}

.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.72rem 0.85rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.sidebar.collapsed .nav-item {
  justify-content: center;
  padding: 0.75rem;
}

.nav-item:hover {
  background: #1e293b;
  color: #ffffff;
  transform: translateX(2px);
}

.sidebar.collapsed .nav-item:hover {
  transform: scale(1.06);
}

.nav-item.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

.nav-label {
  transition: opacity 0.2s ease;
}

.sidebar-footer {
  border-top: 1px solid #1e293b;
  padding-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  overflow: hidden;
}

.sidebar.collapsed .sidebar-footer {
  justify-content: center;
}

.mobile-topbar {
  display: none;
}

.sidebar-backdrop {
  display: none;
}

.user-info {
  font-size: 0.82rem;
  overflow: hidden;
}

.user-info strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-info span {
  color: #94a3b8;
  font-size: 0.75rem;
}

.main-content {
  flex: 1;
  padding: 1.75rem 2rem;
  overflow-y: auto;
  max-width: 1400px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.page-header p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-alt);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger:hover {
  background: #fee2e2;
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.form-group label {
  font-size: 0.83rem;
  font-weight: 600;
  color: #334155;
}

.form-control {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  width: 100%;
}

.form-control:focus {
  outline: 2px solid #c7d2fe;
  border-color: var(--primary);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

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

.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.25s ease, border-color 0.25s ease;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.1);
  border-color: #c7d2fe;
}

.stock-highlight-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stock-highlight-box.low {
  background: #fef2f2;
  border-color: #fecaca;
}

.stock-highlight-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}

.stock-big-num {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stock-bar-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.stock-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn-edit-fancy {
  position: relative;
  overflow: hidden;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.52rem 0.9rem;
  border-radius: 10px;
  border: 1px solid #c7d2fe;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn-edit-fancy::before {
  content: '';
  position: absolute;
  top: 0;
  left: -120%;
  width: 65%;
  height: 100%;
  background: linear-gradient(120deg, transparent 0%, rgba(255, 255, 255, 0.45) 50%, transparent 100%);
  transform: skewX(-20deg);
  transition: left 0.55s ease;
}

.btn-edit-fancy svg {
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn-edit-fancy:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.32);
}

.btn-edit-fancy:hover::before {
  left: 150%;
}

.btn-edit-fancy:hover svg {
  transform: rotate(-10deg) scale(1.12);
}

.btn-edit-fancy:active {
  transform: translateY(0) scale(0.98);
}

.btn-delete-fancy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.52rem 0.72rem;
  border-radius: 10px;
  border: 1px solid #fecaca;
  background: var(--danger-soft);
  color: var(--danger);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

.btn-delete-fancy svg {
  transition: transform 0.25s ease;
}

.btn-delete-fancy:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.28);
}

.btn-delete-fancy:hover svg {
  transform: scale(1.12) rotate(8deg);
}

.btn-delete-fancy:active {
  transform: translateY(0) scale(0.96);
}

.product-img-wrap {
  height: 125px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.product-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), filter 0.35s ease;
  will-change: transform;
}

.product-img-wrap:hover img {
  transform: scale(1.1) rotate(1deg);
  filter: brightness(1.06) contrast(1.03);
}

.product-img-wrap > div {
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), color 0.25s ease;
}

.product-img-wrap:hover > div {
  transform: scale(1.08);
  color: var(--primary) !important;
}

.product-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex: 1;
}

.product-desc {
  font-size: 0.84rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.variants-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.variant-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.76rem;
}

.color-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th, td {
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  background: var(--surface-alt);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}

.modal-content {
  background: var(--surface);
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.86rem;
  margin-bottom: 1rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.mobile-dash-nav {
  display: none;
}

.dash-alerts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1rem;
}

.dash-brief-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dash-brief-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  font-size: 0.84rem;
}

@media (max-width: 768px) {
  .app-layout { flex-direction: column; }
  .mobile-dash-nav {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1.15rem;
  }
  .mobile-dash-btn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.78rem 0.9rem;
    border-radius: 12px;
    border: 1px solid #c7d2fe;
    background: var(--surface);
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 700;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease;
  }
  .mobile-dash-btn:active {
    transform: scale(0.97);
    background: var(--primary-soft);
  }
  .mobile-dash-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--primary-soft);
    color: var(--primary);
    display: grid;
    place-items: center;
    flex-shrink: 0;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1rem;
  }
  .kpi-card {
    padding: 0.85rem 0.9rem;
  }
  .kpi-value {
    font-size: 1.35rem;
  }
  .kpi-icon {
    width: 36px;
    height: 36px;
  }
  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0f172a;
    color: #f8fafc;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #1e293b;
    position: sticky;
    top: 0;
    z-index: 25;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 250px !important;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 45;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar-toggle-btn {
    display: none;
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    z-index: 40;
  }
  .main-content { padding: 1rem; }
}
