:root {
  --surface-50: #fafaf8;
  --surface-100: #f5f1eb;
  --surface-200: #ede9e1;
  --stone-50: #fafaf9;
  --stone-100: #f5f5f4;
  --stone-200: #e7e5e4;
  --stone-300: #d6d3d1;
  --stone-400: #a8a29e;
  --stone-500: #78716c;
  --stone-600: #57534e;
  --stone-700: #44403c;
  --stone-800: #292524;
  --stone-900: #1c1917;
  --amber-50: #fffbeb;
  --amber-500: #f59e0b;
  --amber-600: #d97706;
  --emerald-50: #ecfdf5;
  --emerald-600: #059669;
  --red-50: #fef2f2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --sky-50: #f0f9ff;
  --sky-600: #0284c7;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.06);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--surface-100);
  color: var(--stone-800);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

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

button {
  cursor: pointer;
}

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

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: var(--stone-900);
  color: white;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--amber-500);
  color: white;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
}

.brand-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-subtitle {
  color: var(--stone-400);
  font-size: 10px;
  margin-top: 1px;
}

.nav {
  padding: 4px 8px 20px;
  overflow-y: auto;
}

.nav-section {
  margin: 12px 10px 6px;
  color: rgba(255, 255, 255, 0.34);
  text-transform: uppercase;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--stone-400);
  font-size: 12px;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover,
.nav-link.is-active {
  background: rgba(255, 255, 255, 0.09);
  color: white;
}

.nav-icon {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  flex: 0 0 auto;
}

.main {
  margin-left: 220px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(245, 241, 235, 0.9);
  backdrop-filter: blur(8px);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.mobile-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: white;
  color: var(--stone-600);
  box-shadow: var(--shadow-sm);
}

.global-search {
  position: relative;
  width: min(420px, 48vw);
}

.global-search .input {
  padding-left: 36px;
  height: 38px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--stone-400);
  font-weight: 700;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: white;
  border: 1px solid var(--stone-100);
  border-radius: 9px;
  padding: 7px 10px;
  box-shadow: var(--shadow-sm);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--stone-900);
  color: white;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 700;
}

.content {
  padding: 0 24px 28px;
  flex: 1;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 8px 0 14px;
}

.page-title {
  margin: 0;
  color: var(--stone-900);
  font-size: 18px;
  font-weight: 750;
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--stone-500);
  font-size: 12px;
}

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

.card {
  background: white;
  border: 1px solid var(--stone-100);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.card.pad {
  padding: 16px;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--stone-100);
}

.card-title {
  margin: 0;
  color: var(--stone-700);
  font-size: 13px;
  font-weight: 700;
}

.grid {
  display: grid;
  gap: 12px;
}

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

.dashboard-grid {
  grid-template-columns: 1.15fr 0.85fr;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.stat-card {
  min-height: 84px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--stone-100);
  color: var(--stone-700);
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
}

.stat-icon.amber {
  background: var(--amber-50);
  color: var(--amber-600);
}

.stat-icon.red {
  background: var(--red-50);
  color: var(--red-600);
}

.stat-icon.emerald {
  background: var(--emerald-50);
  color: var(--emerald-600);
}

.stat-label {
  margin: 0 0 4px;
  color: var(--stone-400);
  font-size: 10px;
  font-weight: 700;
}

.stat-value {
  color: var(--stone-900);
  font-size: 20px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--stone-200);
  border-radius: 9px;
  background: white;
  color: var(--stone-800);
  padding: 10px 12px;
  font-size: 13px;
  outline: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.textarea {
  min-height: 86px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--stone-400);
  box-shadow: 0 0 0 3px rgba(168, 162, 158, 0.16);
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--stone-500);
  font-size: 11px;
  font-weight: 700;
}

.field-help {
  margin-top: 5px;
  color: var(--stone-400);
  font-size: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  min-height: 38px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: var(--stone-900);
  color: white;
  box-shadow: var(--shadow-sm);
}

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

.btn-gold {
  background: var(--amber-600);
  color: white;
}

.btn-ghost {
  background: var(--stone-100);
  color: var(--stone-600);
}

.btn-ghost:hover {
  background: var(--stone-200);
}

.btn-line {
  background: white;
  border: 1px solid var(--stone-200);
  color: var(--stone-600);
}

.btn-danger {
  background: var(--red-600);
  color: white;
}

.btn-sm {
  min-height: 30px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 11px;
}

.btn-icon {
  width: 32px;
  min-width: 32px;
  padding: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--stone-100);
  color: var(--stone-600);
  font-size: 10px;
  font-weight: 800;
}

.pill.ok {
  background: var(--emerald-50);
  color: var(--emerald-600);
}

.pill.warn {
  background: var(--amber-50);
  color: var(--amber-600);
}

.pill.danger {
  background: var(--red-50);
  color: var(--red-600);
}

.table-wrap {
  overflow: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(245, 245, 244, 0.94);
  color: var(--stone-500);
  font-weight: 800;
  text-align: left;
  border-bottom: 1px solid var(--stone-200);
  padding: 9px 10px;
}

.table td {
  border-bottom: 1px solid var(--stone-100);
  color: var(--stone-700);
  padding: 9px 10px;
  vertical-align: middle;
}

.table tr:hover td {
  background: var(--stone-50);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

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

.strong {
  color: var(--stone-900);
  font-weight: 800;
}

.flash {
  margin-bottom: 12px;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
}

.flash.success {
  background: var(--emerald-50);
  color: var(--emerald-600);
  border: 1px solid rgba(5, 150, 105, 0.16);
}

.flash.error {
  background: var(--red-50);
  color: var(--red-600);
  border: 1px solid rgba(220, 38, 38, 0.16);
}

.error-list {
  margin: 0;
  padding-left: 18px;
}

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

.product-image {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--stone-100);
  border: 1px solid var(--stone-200);
}

.image-placeholder {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--stone-100);
  border: 1px solid var(--stone-200);
  color: var(--stone-400);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.stock-mobile {
  display: none;
}

.stock-card {
  padding: 12px;
}

.stock-card-head {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: start;
}

.location-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.location-chip {
  display: inline-flex;
  gap: 5px;
  border-radius: 999px;
  background: var(--stone-100);
  padding: 5px 8px;
  font-size: 10px;
  color: var(--stone-600);
  font-weight: 700;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--surface-100);
}

.login-card {
  width: 100%;
  max-width: 380px;
}

.login-brand {
  text-align: center;
  margin-bottom: 26px;
}

.login-brand .brand-mark {
  margin: 0 auto 10px;
  width: 48px;
  height: 48px;
  border-radius: 13px;
  background: var(--stone-900);
  color: var(--amber-500);
  font-size: 18px;
}

.login-brand h1 {
  margin: 0;
  font-size: 19px;
  color: var(--stone-900);
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--stone-500);
  font-size: 12px;
}

.kbd {
  border: 1px solid var(--stone-200);
  border-radius: 5px;
  background: var(--stone-50);
  color: var(--stone-400);
  padding: 2px 5px;
  font-size: 9px;
}

.sticky-tools {
  position: sticky;
  top: 62px;
  z-index: 20;
  background: rgba(245, 241, 235, 0.92);
  backdrop-filter: blur(8px);
  padding: 8px 0;
}

.report-section {
  margin-top: 12px;
}

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

  .dashboard-grid,
  .three-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  body {
    font-size: 14px;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    width: 240px;
  }

  body.menu-open .sidebar {
    transform: translateX(0);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
  }

  .main {
    margin-left: 0;
  }

  .topbar {
    padding: 10px 14px;
  }

  .mobile-menu-btn {
    display: inline-grid;
    place-items: center;
  }

  .global-search {
    width: 100%;
    flex: 1;
  }

  .user-pill {
    display: none;
  }

  .content {
    padding: 0 14px 22px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .actions .btn {
    flex: 1 1 auto;
  }

  .form-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .desktop-only {
    display: none !important;
  }

  .stock-mobile {
    display: grid;
    gap: 10px;
  }

  .table-wrap.mobile-hide {
    display: none;
  }

  .sticky-tools {
    top: 58px;
  }

  .btn {
    min-height: 42px;
  }
}

@media (max-width: 520px) {
  .topbar {
    align-items: stretch;
  }

  .global-search .input {
    height: 44px;
    font-size: 15px;
  }

  .stat-card {
    min-height: 76px;
  }

  .card.pad {
    padding: 13px;
  }

  .stock-card-head {
    grid-template-columns: 44px 1fr;
  }

  .stock-card-head .pill {
    grid-column: 2;
    width: max-content;
  }
}
