:root {
  --bg: #050914;
  --surface: #0b1222;
  --surface-2: #111b33;
  --border: rgba(56, 189, 248, 0.18);
  --border-strong: rgba(56, 189, 248, 0.36);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --danger: #f87171;
  --ok: #34d399;
  --warn: #fbbf24;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(circle at top right, #0f1f3f 0%, var(--bg) 52%);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.pw-muted { color: var(--muted); font-size: 13px; margin: 0; line-height: 1.45; }

/* Toasts */
.pw-toast-root {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pw-toast {
  padding: 10px 14px;
  border-radius: 12px;
  background: #0f172a;
  border: 1px solid var(--border-strong);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}
.pw-toast.error { border-color: rgba(248, 113, 113, 0.6); color: #fecaca; }

/* Buttons & Inputs */
.pw-btn {
  border: 1px solid transparent;
  border-radius: 11px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}
.pw-btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #03111f;
  font-weight: 700;
}
.pw-btn-glass {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
}
.pw-btn-danger {
  background: rgba(239, 68, 68, 0.14);
  border-color: rgba(239, 68, 68, 0.38);
  color: #fca5a5;
}
.pw-btn-sm { padding: 7px 11px; font-size: 12.5px; }
.pw-btn-xs { padding: 5px 9px; font-size: 11.5px; border-radius: 8px; }
.pw-btn-block { width: 100%; }

.pw-form { display: flex; flex-direction: column; gap: 12px; }
.pw-field { display: flex; flex-direction: column; gap: 5px; }
.pw-field span { font-size: 12px; color: #cbd5e1; font-weight: 600; }
.pw-field input, .pw-field select, .pw-field textarea, .pw-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(5, 9, 20, 0.72);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}
.pw-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pw-error { color: #fca5a5; font-size: 12.5px; margin: 0; }
.pw-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

/* Login */
.pw-login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.pw-login-card {
  width: 100%;
  max-width: 420px;
  padding: 28px 24px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.pw-login-brand { display: flex; align-items: center; gap: 12px; }
.pw-login-brand img { width: 44px; height: 44px; border-radius: 12px; }
.pw-eyebrow { font-size: 10.5px; letter-spacing: 1.6px; color: var(--accent); font-weight: 700; display: block; }
.pw-login-brand h1 { margin: 2px 0 0; font-size: 22px; font-family: "Space Grotesk", sans-serif; }
.pw-foot-note { margin: 4px 0 0; font-size: 11.5px; color: var(--muted); text-align: center; }

/* App Shell */
.pw-app-view { min-height: 100vh; display: flex; flex-direction: column; }
.pw-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(8, 13, 28, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.pw-brand-bar { display: flex; align-items: center; gap: 10px; }
.pw-brand-bar img { width: 34px; height: 34px; border-radius: 10px; }
.pw-brand-bar strong { display: block; font-size: 14.5px; }
.pw-sub-meta { font-size: 11.5px; color: var(--accent); }
.pw-tabs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.pw-tab {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pw-tab.active {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--accent);
  color: #fff;
}
.pw-badge {
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.12);
}
#pw-chat-badge { background: #ef4444; color: #fff; }
.pw-top-actions { display: flex; gap: 8px; }
.pw-main { flex: 1; padding: 16px; max-width: 1320px; width: 100%; margin: 0 auto; }

/* Chat Workspace */
.pw-chat-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 110px);
  min-height: 480px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}
.pw-chat-sidebar {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: rgba(7, 11, 24, 0.9);
  min-height: 0;
}
.pw-chat-side-head {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pw-chat-side-head > div { display: flex; align-items: center; justify-content: space-between; }
.pw-chat-side-head h2 { margin: 0; font-size: 15px; }
.pw-live-pill { font-size: 11px; color: var(--ok); font-weight: 700; }
.pw-chat-side-head input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 12.5px;
}
.pw-chat-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.pw-chat-item {
  width: 100%;
  text-align: left;
  padding: 10px 11px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(255, 255, 255, 0.02);
  color: #fff;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.pw-chat-item.active {
  background: rgba(56, 189, 248, 0.14);
  border-color: var(--accent);
}
.pw-chat-item-info { min-width: 0; flex: 1; }
.pw-chat-item-info strong { display: block; font-size: 13px; }
.pw-chat-item-info small { display: block; font-size: 11px; color: #7dd3fc; margin-top: 1px; }
.pw-chat-item-info span {
  display: block;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}
.pw-unread-dot {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pw-chat-main { display: flex; flex-direction: column; min-height: 0; background: #060b16; }
.pw-chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 8px;
}
.pw-chat-active { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.pw-chat-active-head {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 10px;
}
.pw-mobile-back { display: none; }
.pw-chat-peer { flex: 1; min-width: 0; }
.pw-chat-peer strong { display: block; font-size: 14px; }
.pw-chat-peer span { font-size: 11.5px; display: block; }
.pw-privacy-tag {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.12);
  border: 1px solid rgba(52, 211, 153, 0.3);
  color: #6ee7b7;
  white-space: nowrap;
}
.pw-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pw-msg {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 13px;
  font-size: 13.5px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pw-msg.mine {
  align-self: flex-end;
  background: rgba(56, 189, 248, 0.18);
  border: 1px solid rgba(56, 189, 248, 0.38);
}
.pw-msg.theirs {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.pw-msg-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 11px; color: var(--muted); }
.pw-msg img { max-width: 240px; border-radius: 10px; cursor: pointer; margin-top: 2px; border: 1px solid rgba(255,255,255,.15); }
.pw-att-preview {
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
}
.pw-att-preview img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; }
.pw-chat-form {
  padding: 10px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--surface-2);
  display: flex;
  gap: 8px;
  align-items: center;
}
.pw-chat-form input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(5, 9, 20, 0.72);
  color: #fff;
  font-size: 13.5px;
}

/* Sections, Grids & Cards */
.pw-sec-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.pw-sec-head h2 { margin: 0 0 4px; font-size: 19px; }
.pw-sec-actions { display: flex; gap: 8px; align-items: center; }
.pw-grid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.pw-stack-list { display: flex; flex-direction: column; gap: 10px; }
.pw-two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pw-card {
  padding: 16px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.pw-card h3 { margin: 0 0 12px; font-size: 15.5px; }
.pw-prod-card {
  padding: 14px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.pw-prod-top { display: flex; gap: 12px; }
.pw-prod-top img { width: 68px; height: 84px; object-fit: cover; border-radius: 10px; background: #0f172a; flex-shrink: 0; }
.pw-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
}
.pw-pill.ok { background: rgba(52, 211, 153, 0.16); color: #6ee7b7; }
.pw-pill.pend { background: rgba(251, 191, 36, 0.16); color: #fde68a; }
.pw-pill.rej { background: rgba(248, 113, 113, 0.16); color: #fca5a5; }
.pw-kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pw-kpi {
  padding: 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.pw-kpi span { font-size: 12px; color: var(--muted); display: block; }
.pw-kpi strong { font-size: 20px; margin-top: 4px; display: block; }
.pw-row-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pw-mini-qr { width: 72px; height: 72px; object-fit: contain; background: #fff; padding: 4px; border-radius: 8px; }

/* Modals */
.pw-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(2, 6, 18, 0.78);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 16px;
}
.pw-modal-sheet {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  border-radius: 18px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
}
.pw-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}
.pw-subbox {
  padding: 12px;
  border-radius: 12px;
  background: rgba(5, 9, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.pw-subbox-title { font-size: 12px; font-weight: 700; display: block; margin-bottom: 8px; }
.pw-tallas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.pw-talla-cell { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; }
.pw-talla-cell input { padding: 6px 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,.15); background: #0b1222; color: #fff; }
.pw-photos-grid { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.pw-photo-chip { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid rgba(255,255,255,.15); }
.pw-photo-chip img { width: 100%; height: 100%; object-fit: cover; }
.pw-photo-chip button { position: absolute; top: 2px; right: 2px; border: none; background: rgba(0,0,0,.7); color: #fff; border-radius: 999px; width: 20px; height: 20px; cursor: pointer; font-size: 11px; }
.pw-hsv-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.pw-hsv-sv { border-radius: 10px; cursor: crosshair; border: 1px solid rgba(255,255,255,.18); }
.pw-hsv-controls { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 8px; }
.pw-col-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.pw-col-item { padding: 9px 10px; border-radius: 10px; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.1); display: flex; flex-direction: column; gap: 6px; }
.pw-col-swatch { width: 14px; height: 14px; border-radius: 999px; display: inline-block; border: 1px solid rgba(255,255,255,.3); }
.pw-info-pill { margin: 0; font-size: 12.5px; color: var(--accent); font-weight: 700; }
.pw-modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.pw-lightbox-inner { position: relative; max-width: 92vw; max-height: 90vh; }
.pw-lightbox-inner img { max-width: 100%; max-height: 86vh; border-radius: 14px; }

@media (max-width: 820px) {
  .pw-two-col { grid-template-columns: 1fr; }
  .pw-chat-shell { grid-template-columns: 1fr; height: calc(100vh - 140px); }
  .pw-chat-shell.has-active .pw-chat-sidebar { display: none; }
  .pw-chat-shell:not(.has-active) .pw-chat-main { display: none; }
  .pw-mobile-back { display: inline-flex; }
  .pw-field-grid { grid-template-columns: 1fr; }
}
