/*
 * Woodland Retail Partner Portal — design tokens + auth screens (FRONTEND_REFERENCE).
 */

@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  --pine: #004648;
  --pine-ink: #002f30;
  --karaka: #00a079;
  --karaka-deep: #007a5c;
  --beige-1: #f7f2e8;
  --beige-2: #d4ccb8;
  --beige-3: #efe6d6;
  --beige-line: #e4d9c4;
  --stone: #6b6055;
  --ink: #1b1f1f;
  --ink-2: #3d4544;
  --ink-3: #5c6463;
  --ink-4: #8a8f8e;
  --white: #ffffff;
  --warn: #b45309;
  --err: #b91c1c;
  --err-bg: #fee2e2;
  --ok-bg: #ecfdf5;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

html:has(.portal-page) {
  height: 100%;
}

body:has(.portal-page) {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Manrope", system-ui, sans-serif;
  background: var(--beige-3);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.mono { font-family: "JetBrains Mono", monospace; }

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-3);
}

.eyebrow.accent { color: var(--karaka-deep); }

.flash {
  max-width: 1280px;
  margin: 16px auto 0;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.flash.notice {
  background: var(--ok-bg);
  color: var(--pine);
  border: 1px solid rgba(0, 160, 121, 0.25);
}

.flash.alert {
  background: var(--err-bg);
  color: var(--err);
  border: 1px solid rgba(185, 28, 28, 0.2);
}

.auth-page {
  min-height: 100vh;
  padding: 24px 16px 40px;
}

.auth {
  max-width: 1280px;
  margin: 0 auto;
  background: var(--white);
  border: 1px solid var(--beige-line);
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 520px;
}

.auth-brand {
  position: relative;
  background: var(--pine);
  color: var(--beige-1);
  padding: 40px;
  overflow: hidden;
}

.auth-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.06;
  background: repeating-linear-gradient(135deg, #fff 0 1px, transparent 1px 11px);
}

.auth-brand::after {
  content: "";
  position: absolute;
  right: -80px;
  bottom: -80px;
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, var(--karaka) 0%, transparent 70%);
  opacity: 0.18;
}

.auth-brand-inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.mark {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.brand-logo {
  height: 64px;
  width: auto;
  display: block;
}

.brand-logo-mini {
  height: 40px;
  width: auto;
  display: block;
}

.mark-box {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: var(--karaka);
  color: var(--pine-ink);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 18px;
}

.mark-name { font-weight: 800; letter-spacing: 0.3px; }
.mark-sub { font-size: 11px; color: rgba(247, 242, 232, 0.7); letter-spacing: 0.4px; }

.auth-hero { margin-top: auto; margin-bottom: auto; }
.auth-hero h2 { font-size: 30px; line-height: 1.15; margin: 8px 0 0; font-weight: 800; }

.auth-foot {
  font-size: 11px;
  color: rgba(247, 242, 232, 0.65);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-form {
  padding: 40px;
  display: flex;
  flex-direction: column;
}

.auth-form-top {
  display: flex;
  justify-content: flex-end;
  font-size: 13px;
  color: var(--karaka-deep);
  font-weight: 600;
}

.auth-form-top a { text-decoration: none; }
.auth-form-top a:hover { text-decoration: underline; }

.auth-mini-mark {
  display: none;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
}

.auth-mini-mark .mark-box { width: 28px; height: 28px; font-size: 15px; }
.auth-mini-mark .mark-name { color: var(--ink); font-size: 14px; }

.auth-body { margin: auto 0; }
.auth-body h1 { font-size: 26px; font-weight: 800; margin: 6px 0 6px; }
.auth-body .subtitle { color: var(--ink-2); margin: 0 0 22px; }

.field { margin-bottom: 18px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }

.field-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--beige-2);
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: var(--white);
}

.field-input:focus {
  outline: none;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(0, 70, 72, 0.1);
}

.btn {
  height: 48px;
  width: 100%;
  border: none;
  border-radius: 6px;
  background: var(--pine);
  color: var(--beige-1);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn:hover { background: var(--pine-ink); }
.btn:disabled { cursor: wait; opacity: 0.92; }
.btn.is-loading {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: var(--beige-1);
  border-radius: 50%;
  animation: btn-spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

.auth-meta { margin-top: 16px; font-size: 12px; color: var(--ink-3); }
.auth-meta a { color: var(--karaka-deep); font-weight: 600; text-decoration: none; }
.auth-meta a:hover { text-decoration: underline; }

.pin-row { display: flex; gap: 10px; margin: 6px 0 18px; }

.pin-box {
  width: 56px;
  height: 64px;
  border: 1px solid var(--beige-2);
  border-radius: 6px;
  text-align: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 26px;
  background: var(--white);
}

.pin-box:focus {
  outline: none;
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(0, 70, 72, 0.1);
}

.countdown {
  font-family: "JetBrains Mono", monospace;
  color: var(--ink-3);
  font-size: 13px;
}

.portal-placeholder {
  max-width: 720px;
  margin: 48px auto;
  padding: 32px;
  background: var(--white);
  border: 1px solid var(--beige-line);
  border-radius: 10px;
}

.portal-placeholder h1 { margin: 0 0 8px; font-size: 22px; }
.portal-placeholder p { color: var(--ink-3); margin: 0 0 20px; }

/* ───────── Stock portal ───────── */
.portal-page {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background: var(--white);
  overflow: hidden;
}

.topbar {
  flex-shrink: 0;
  height: 64px;
  background: var(--pine);
  color: var(--beige-1);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--pine-ink);
}

.topbar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.topbar-logo {
  height: 52px;
  width: auto;
  display: block;
}
.topbar-logo-icon { display: none; }

.topbar-divider { width: 1px; height: 26px; background: rgba(247, 242, 232, 0.25); flex-shrink: 0; }
.topbar-context {
  font-size: 12px;
  color: rgba(247, 242, 232, 0.85);
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.3;
}
.topbar-context strong { color: var(--beige-1); font-size: 13px; }
.topbar-company { color: rgba(247, 242, 232, 0.7); font-size: 11px; }
.topbar-spacer { flex: 1; }
.topbar-nav { display: flex; gap: 18px; font-size: 13px; font-weight: 600; }
.topbar-nav a,
.topbar-nav span { text-decoration: none; padding: 4px 0; color: rgba(247, 242, 232, 0.8); }
.topbar-nav a.active { color: var(--beige-1); border-bottom: 2px solid var(--karaka); }
.topbar-nav .future {
  opacity: 0.4;
  cursor: not-allowed;
  position: relative;
}
.topbar-nav .future[data-tooltip]:hover::after,
.topbar-nav .future[data-tooltip]:focus::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--pine-ink);
  color: var(--beige-1);
  font-size: 11px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 60;
  opacity: 1;
  pointer-events: none;
}
.acct-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--karaka); color: var(--pine-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 12px;
}
.sign-out-link {
  background: none; border: none; color: rgba(247, 242, 232, 0.85); font: inherit;
  font-size: 12px; cursor: pointer; text-decoration: underline; padding: 0;
}

.subbar {
  flex-shrink: 0;
  height: 44px;
  background: var(--beige-1);
  border-bottom: 1px solid var(--beige-line);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  font-size: 13px;
}
.subbar .crumb { color: var(--ink); font-weight: 600; }

.shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}
.sidebar {
  min-height: 0;
  border-right: 1px solid var(--beige-line);
  padding: 0 14px 18px;
  background: var(--beige-1);
  overflow-y: auto;
}
.sidebar-head {
  padding: 18px 6px 14px;
  border-bottom: 1px solid var(--beige-line);
  margin-bottom: 14px;
}
.sidebar-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--ink);
}
.sidebar-head p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.4;
}
.side-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase;
  color: var(--ink-3); margin: 4px 6px 8px; display: flex; justify-content: space-between;
}
.side-item {
  display: flex; justify-content: space-between; align-items: center; padding: 7px 10px;
  border-radius: 6px; cursor: pointer; font-size: 13px; text-decoration: none; color: inherit;
}
.side-item:hover { background: var(--beige-3); }
.side-item.active { background: var(--pine); color: var(--beige-1); }
.side-item .qty { font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--ink-3); }
.side-item.active .qty { color: rgba(247, 242, 232, 0.8); }
.cat-group { margin-bottom: 2px; }
.cat-header {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0;
}
.cat-header.active .cat-link { color: var(--beige-1); }
.cat-header.active .caret { color: rgba(247, 242, 232, 0.85); }
.cat-header.active .cat-toggle:hover { background: rgba(247, 242, 232, 0.12); }
.cat-header.child-active .cat-label { color: var(--pine); font-weight: 700; }
.cat-header.child-active .qty { color: var(--ink); font-weight: 600; }
.cat-link {
  flex: 1;
  min-width: 0;
  padding: 7px 4px;
  text-decoration: none;
  color: inherit;
  border-radius: 6px;
}
.cat-link:hover { background: var(--beige-3); }
.cat-header.active .cat-link:hover { background: transparent; }
.cat-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  padding: 7px 0 7px 6px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: inherit;
  cursor: pointer;
  border-radius: 6px;
}
.cat-toggle:hover { background: var(--beige-3); }
.cat-header .qty { padding-right: 10px; flex-shrink: 0; }
.caret { display: inline-block; width: 14px; color: var(--ink-3); transition: transform 0.12s; flex-shrink: 0; }
.caret.open { transform: rotate(90deg); }
.side-sub { padding-left: 8px; }
.side-item-sub { padding-left: 28px !important; font-size: 12.5px; }
.side-section { margin-bottom: 18px; }
.checkrow {
  display: flex; align-items: center; gap: 9px; padding: 6px 10px; cursor: pointer;
  font-size: 13px; border-radius: 6px; text-decoration: none; color: inherit;
}
.checkrow:hover { background: var(--beige-3); }
.checkrow.active { background: rgba(0, 70, 72, 0.08); font-weight: 600; }
.check {
  width: 15px; height: 15px; border: 1px solid var(--beige-2); border-radius: 4px; display: inline-block;
}
.check.on { background: var(--pine); border-color: var(--pine); position: relative; }
.check.on::after {
  content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px;
  border: solid var(--beige-1); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.side-count { margin-left: auto; font-family: "JetBrains Mono", monospace; font-size: 12px; color: var(--ink-3); }

.main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.main-pad {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px 24px 0;
}
.stock-sticky-head { flex-shrink: 0; }
.stock-table-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 24px;
}
.page-head h1 { font-size: 22px; font-weight: 800; margin: 0; }
.page-head .sub { color: var(--ink-3); font-size: 13px; margin-top: 2px; }
.page-head-mobile { display: none; }

.controls {
  display: grid; grid-template-columns: minmax(240px, 1fr) auto auto auto; gap: 12px;
  margin: 16px 0 12px; align-items: center;
}
.search { position: relative; min-height: 44px; }
.search input {
  width: 100%; height: 44px; padding: 0 38px; border: 1px solid var(--beige-2); border-radius: 6px;
  font-family: inherit; font-size: 14px; box-sizing: border-box;
}
.search input:focus { outline: none; border-color: var(--pine); box-shadow: 0 0 0 3px rgba(0, 70, 72, 0.1); }
.search-ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-4); }
.search-hint {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px;
  border: 1px solid var(--beige-2); border-radius: 4px; display: grid; place-items: center;
  color: var(--ink-4); font-family: "JetBrains Mono", monospace; font-size: 12px;
}
.search-clear {
  position: absolute; right: 36px; top: 50%; transform: translateY(-50%);
  text-decoration: none; color: var(--ink-3); font-size: 18px; line-height: 1;
}
.seg {
  display: flex; align-items: center; flex-wrap: nowrap; gap: 2px; border: 1px solid var(--beige-2);
  border-radius: 6px; padding: 3px; background: var(--white); height: 44px; box-sizing: border-box;
}
.seg-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.8px; text-transform: uppercase;
  color: var(--ink-3); padding: 0 8px;
}
.seg-opt {
  padding: 6px 12px; border-radius: 4px; font-size: 13px; font-weight: 600; line-height: 1.2;
  color: var(--ink-2); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.seg-opt.on { background: var(--pine); color: var(--beige-1); }

.chips {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; font-size: 12px;
}
.chips .label { font-weight: 700; letter-spacing: 1px; color: var(--ink-3); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--beige-1);
  border: 1px solid var(--beige-line); border-radius: 999px; padding: 4px 10px;
}
.chip .x { cursor: pointer; color: var(--ink-3); text-decoration: none; }
.chip-clear { color: var(--karaka-deep); font-weight: 600; cursor: pointer; text-decoration: none; }
.result-count { margin-left: auto; color: var(--ink-3); }
.result-count strong { color: var(--ink); }

.table-wrap { border: 1px solid var(--beige-line); border-radius: 8px; overflow: visible; }
table.stock { width: 100%; border-collapse: collapse; }
table.stock thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--pine); color: var(--beige-1); font-size: 11px; font-weight: 700;
  letter-spacing: 0.8px; text-transform: uppercase; text-align: left; padding: 11px 12px; white-space: nowrap;
}
table.stock thead th.num { text-align: right; }
table.stock thead th.wh-on { background: var(--pine-ink); border-bottom: 2px solid var(--karaka); }
table.stock tbody td {
  padding: 8px 12px; border-bottom: 1px solid var(--beige-line); height: 40px; vertical-align: middle;
}
table.stock tbody tr:hover td { background: rgba(0, 70, 72, 0.025); }
table.stock td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.stock td.wh-on { background: rgba(0, 160, 121, 0.04); }
table.stock td.sku { font-family: "JetBrains Mono", monospace; font-size: 12.5px; color: var(--pine); font-weight: 500; }
table.stock td.name { font-weight: 600; }
.name-sub { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 400; font-family: "JetBrains Mono", monospace; }
table.stock td.cat { font-size: 12.5px; }
table.stock td.cat .range { display: block; font-weight: 600; color: var(--ink); font-size: 13px; }
table.stock td.cat .category { display: block; color: var(--ink-3); font-size: 11.5px; margin-top: 1px; }
.av { font-weight: 700; font-size: 13px; }
.av .unit { font-weight: 500; color: var(--ink-3); font-size: 11px; margin-left: 2px; }
.av.t-high, .av.t-mid { color: var(--pine); }
.av.t-low { color: var(--ink); }
.av.t-low::before { content: "▲ "; color: var(--warn); font-size: 10px; }
.av.t-low[data-tooltip] { position: relative; cursor: help; }
.av.t-low[data-tooltip]:hover::after,
.av.t-low[data-tooltip]:focus::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--white);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.35;
  padding: 6px 10px;
  border-radius: 4px;
  white-space: normal;
  width: max-content;
  max-width: 220px;
  text-align: center;
  z-index: 60;
  opacity: 1;
  pointer-events: none;
}
.av.t-out { color: var(--stone); text-decoration: line-through; }
.av.t-indent { color: var(--ink-3); font-style: italic; }
.av.wh-qty { font-weight: 600; color: var(--ink-2); }
.av.wh-qty .unit { font-weight: 500; color: var(--ink-3); font-size: 11px; margin-left: 2px; }
.next-arr .d { font-weight: 600; font-size: 12.5px; }
.next-arr .q { display: block; font-size: 11px; color: var(--ink-3); }
.next-arr .none { color: var(--ink-4); }

.cards { display: none; }
.card {
  border: 1px solid var(--beige-line); border-radius: 8px; padding: 12px; margin-bottom: 10px; background: var(--white);
}
.card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card-sku { font-family: "JetBrains Mono", monospace; font-size: 12.5px; color: var(--pine); font-weight: 500; }
.card-name { font-weight: 600; margin-top: 4px; }
.card-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.card-wh {
  display: flex; gap: 18px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--beige-line); font-size: 12px;
}
.card-wh .k { color: var(--ink-3); display: block; font-size: 10.5px; letter-spacing: 0.6px; text-transform: uppercase; }
.card-next { margin-top: 6px; font-size: 12px; color: var(--ink-3); }

.filter-btn {
  display: none; height: 44px; box-sizing: border-box; border: 1px solid var(--beige-2); border-radius: 6px; background: var(--white);
  font-family: inherit; font-weight: 600; font-size: 13px; align-items: center; justify-content: center;
  gap: 6px; cursor: pointer;
}
.filter-drawer-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.35); z-index: 40;
}
.filter-drawer-backdrop.open { display: block; }

.empty-state {
  border: 1px dashed var(--beige-2); border-radius: 8px; padding: 32px; text-align: center; color: var(--ink-3);
}
.empty-state h2 { margin: 0 0 8px; color: var(--ink); font-size: 18px; }
.empty-clear { color: var(--karaka-deep); font-weight: 600; text-decoration: none; }

@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .page-head-mobile { display: block; margin-bottom: 4px; }
  .sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 88vw);
    z-index: 50;
    overflow-y: auto;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
  }
  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
  }
  .filter-btn { display: flex; }
  .controls { grid-template-columns: 1fr auto auto auto; }
}

body.filter-drawer-open { overflow: hidden; }

@media (max-width: 640px) {
  .topbar {
    height: 52px;
    padding: 0 14px;
    gap: 10px;
  }
  .topbar-logo-full { display: none; }
  .topbar-logo-icon {
    display: block;
    height: 34px;
    width: 34px;
    object-fit: contain;
  }
  .topbar-divider,
  .topbar-context { display: none; }
  .topbar-nav { gap: 12px; font-size: 12px; }
  .topbar-nav .future { display: none; }
  .acct-chip .nm { display: none; }
  .sign-out-link { font-size: 11px; }
  .controls { grid-template-columns: 1fr; gap: 8px; }
  .seg { flex-wrap: wrap; height: auto; min-height: 44px; }
  .seg-opt { padding: 5px 10px; font-size: 12px; }
  .search-hint { display: none; }
  .table-wrap { border: none; background: transparent; }
  table.stock { display: none; }
  .cards { display: block; }
  .main-pad { padding: 14px 14px 0; }
  .stock-table-scroll { padding-bottom: 14px; }
}

@media (max-width: 1024px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .auth-mini-mark { display: flex; }
}

@media (max-width: 640px) {
  .auth-form { padding: 26px; }
  .auth-body h1 { font-size: 22px; }
  .pin-box { width: 44px; height: 52px; font-size: 22px; }
  .pin-row { gap: 7px; }
}
