@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800;1,9..40,400&display=swap');

:root {
  --font-sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --color-primary: #0d9488;
  --color-primary-dark: #0f766e;
  --color-primary-light: #f0fdfa;
  --color-primary-border: #99f6e4;
  --bg-main: #f4f5f7;
  --topbar-bg: #ffffff;
  --topbar-border: #e9eaec;
  --color-text-1: #111827;
  --color-text-2: #6b7280;
  --color-text-3: #9ca3af;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --radius: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.06);
  --shadow: 0 4px 16px rgb(0 0 0 / 0.08);
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --ok-bg: #ecfdf5;
  --ok: #065f46;
  --sidebar-bg: #111318;
  --sidebar-border: rgb(255 255 255 / 0.07);
  --sidebar-width: 252px;
  --nav-hover-bg: rgb(255 255 255 / 0.055);
  --nav-active-bg: rgb(255 107 53 / 0.13);
  --nav-active-color: #ff6b35;
  --oms-primary: #ff6b35;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-main);
  color: var(--color-text-1);
  font-family: var(--font-sans);
}

.hidden {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 0.5rem 0.9rem;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.btn--dark {
  background: #1f2937;
  color: #fff;
}

.btn--ghost {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-1);
}

.btn--ghost:hover:not(:disabled) {
  background: #f9fafb;
}

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

.btn--block {
  width: 100%;
}

.btn--sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
}

.btn--oos {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.btn--restock {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

/* Auth */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at top, #ccfbf1 0%, transparent 55%),
    var(--bg-main);
}

.auth-card {
  width: min(420px, 100%);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
  margin-bottom: 1.25rem;
}

.auth-brand h1 {
  margin: 0;
  font-size: 1.25rem;
}

.auth-brand p {
  margin: 0.15rem 0 0;
  color: var(--color-text-2);
  font-size: 0.875rem;
}

.auth-form label {
  display: block;
  margin-bottom: 0.85rem;
}

.auth-form span {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-2);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.auth-form input {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  font: inherit;
}

.auth-error {
  color: var(--danger);
  font-size: 0.875rem;
  margin: 0 0 0.75rem;
}

.auth-handoff {
  text-align: center;
  padding: 1.5rem;
  color: var(--color-text-2);
}

.auth-foot {
  margin: 1rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-text-2);
  text-align: center;
}

.auth-foot a {
  color: var(--color-primary-dark);
}

/* App shell — OMS-style sidebar + main */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg-main);
}

.shell-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: #e8ecf7;
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.15rem 1rem 1rem;
  border-bottom: 1px solid rgb(255 255 255 / 0.1);
  flex-shrink: 0;
}

.sidebar-brand img {
  border-radius: 8px;
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-app {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 0.5rem;
  overflow-y: auto;
  flex: 1;
}

.sidebar-nav a,
.sidebar-nav-group-toggle,
.sidebar-nav-action-link,
.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  color: rgb(255 255 255 / 0.85);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
  border: 0;
  background: transparent;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition:
    background 0.12s ease,
    color 0.12s ease;
}

.sidebar-nav a:hover,
.sidebar-nav-group-toggle:hover,
.sidebar-nav-action-link:hover,
.sidebar-logout:hover {
  background: var(--nav-hover-bg);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-color);
  position: relative;
}

.sidebar-nav a.active::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--oms-primary);
  border-radius: 0 3px 3px 0;
}

.nav-ico {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
  opacity: 0.92;
}

.sidebar-nav a.active .nav-ico {
  opacity: 1;
}

.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin: 0.15rem 0;
}

.sidebar-nav-group-toggle .sidebar-nav-chevron {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.75;
  transition: transform 0.15s ease;
}

.sidebar-nav-group-toggle[aria-expanded='true'] .sidebar-nav-chevron {
  transform: rotate(180deg);
}

.sidebar-nav-group--open .sidebar-nav-group-toggle {
  background: var(--nav-active-bg);
  color: var(--nav-active-color);
}

.sidebar-nav-sub {
  display: none;
  flex-direction: column;
  gap: 0.15rem;
  padding-left: 0.35rem;
}

.sidebar-nav-group--open .sidebar-nav-sub {
  display: flex;
}

.sidebar-nav-sub a {
  padding-left: 1.35rem;
  font-size: 0.86rem;
}

.sidebar-nav-external {
  margin-top: 0.35rem;
  border: 1px solid rgb(255 107 53 / 0.28) !important;
  background: rgb(255 107 53 / 0.08) !important;
}

.sidebar-nav-external:hover {
  background: rgb(255 107 53 / 0.16) !important;
  border-color: rgb(255 107 53 / 0.42) !important;
}

.sidebar-footer {
  padding: 0.65rem 0.55rem 1rem;
  border-top: 1px solid rgb(255 255 255 / 0.08);
}

.sidebar-logout {
  color: #fca5a5;
}

.topbar__menu {
  display: none;
}

.topbar {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.topbar__logo {
  border-radius: 8px;
}

.topbar__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar__email {
  font-size: 0.8125rem;
  color: var(--color-text-2);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-main {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

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

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(var(--sidebar-width), 86vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgb(15 23 42 / 0.45);
    z-index: 25;
  }

  .sidebar-backdrop.hidden {
    display: none !important;
  }

  .topbar__menu {
    display: inline-flex;
  }
}

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.25rem 1.35rem;
  border-radius: var(--radius);
  border: 1px solid rgb(13 148 136 / 0.15);
  background: linear-gradient(135deg, #fff 0%, #f0fdfa 100%);
  box-shadow: var(--shadow-sm);
}

.hero h1 {
  margin: 0;
  font-size: 1.35rem;
}

.hero p {
  margin: 0.25rem 0 0;
  color: var(--color-text-2);
  font-size: 0.875rem;
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.banner {
  margin: 0;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.banner--error {
  background: var(--danger-bg);
  border: 1px solid #fecaca;
  color: var(--danger);
}

.banner--ok {
  background: var(--ok-bg);
  border: 1px solid #a7f3d0;
  color: var(--ok);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem;
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.tab {
  border: 0;
  background: transparent;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-2);
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: var(--color-primary-dark);
  box-shadow: var(--shadow-sm);
}

.badge {
  margin-left: 0.35rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.625rem;
  font-weight: 800;
}

.badge--danger {
  background: #fee2e2;
  color: #991b1b;
}

.panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.65rem;
  padding: 0.85rem;
  border-bottom: 1px solid #f3f4f6;
}

.toolbar--compact {
  border-bottom: 1px solid #f3f4f6;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 140px;
}

.field--grow {
  flex: 1;
  min-width: 180px;
}

.field span {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-3);
}

.field input,
.field select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.875rem;
  background: #fff;
}

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

.table-wrap--modal {
  max-height: min(55vh, 520px);
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.data-table th {
  padding: 0.65rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-2);
  background: #f8fafc;
  border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;
}

.data-table td {
  padding: 0.7rem 0.75rem;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
}

.data-table--dense td,
.data-table--dense th {
  padding: 0.45rem 0.55rem;
}

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

.data-table .check {
  width: 2rem;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.empty {
  text-align: center !important;
  color: var(--color-text-2);
  padding: 3rem 1rem !important;
}

.product-cell {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.product-cell img,
.product-cell .thumb {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: #f3f4f6;
  flex-shrink: 0;
}

.product-cell .thumb {
  display: grid;
  place-items: center;
  color: var(--color-text-3);
  font-size: 0.7rem;
}

.product-cell strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 280px;
}

.product-cell .meta {
  font-size: 0.7rem;
  color: var(--color-text-2);
  font-family: ui-monospace, monospace;
}

.pill {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 700;
}

.pill--on {
  background: #d1fae5;
  color: #065f46;
}

.pill--off {
  background: #f3f4f6;
  color: #6b7280;
}

.pill--oos {
  background: #fee2e2;
  color: #991b1b;
}

.avail--low {
  color: #b91c1c;
  font-weight: 700;
}

.avail--ok {
  color: #065f46;
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem;
}

.cogs-input {
  width: 5.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  text-align: right;
  font: inherit;
  font-family: ui-monospace, monospace;
  font-size: 0.8125rem;
}

.cogs-input--missing {
  border-color: #fca5a5;
  background: #fef2f2;
}

.stock-input {
  width: 4.5rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.25rem 0.35rem;
  text-align: right;
  font: inherit;
  font-size: 0.8125rem;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 0.45);
}

.modal__card {
  position: relative;
  width: min(480px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem 1.15rem;
}

.modal__card--wide {
  width: min(1100px, 100%);
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.modal__head h2 {
  margin: 0;
  font-size: 1.1rem;
}

.modal__sub {
  margin: 0.2rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-text-2);
}

.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

.hint {
  margin: 0.65rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-text-2);
  line-height: 1.4;
}

.confirm-list {
  margin: 0.75rem 0 0;
  padding: 0.65rem 0.85rem;
  max-height: 180px;
  overflow: auto;
  list-style: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #f8fafc;
  font-size: 0.8125rem;
}

.confirm-list li {
  padding: 0.25rem 0;
  border-bottom: 1px solid #eef2f7;
}

.confirm-list li:last-child {
  border-bottom: 0;
}

.confirm-list .meta {
  color: var(--color-text-2);
  font-size: 0.75rem;
}

.progress-panel {
  margin-top: 0.35rem;
  padding: 0.85rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-primary-border);
  background: var(--color-primary-light);
}

.progress-panel__head {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.progress-panel__detail {
  margin: 0.45rem 0 0.65rem;
  font-size: 0.8125rem;
  color: var(--color-text-2);
  word-break: break-word;
}

.progress-panel__note {
  margin: 0.55rem 0 0;
  font-size: 0.75rem;
  color: var(--color-text-2);
  line-height: 1.35;
}

.progress-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgb(13 148 136 / 0.25);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: inv-spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes inv-spin {
  to {
    transform: rotate(360deg);
  }
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: var(--color-primary);
  transition: width 0.25s ease;
}

.oos-live-progress {
  margin: 0 0.85rem 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-primary-border);
  background: var(--color-primary-light);
  font-size: 0.8125rem;
  color: var(--color-text-1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (max-width: 720px) {
  .topbar__email {
    display: none;
  }

  .hero {
    align-items: flex-start;
  }

  .product-cell strong {
    max-width: 160px;
  }
}
