:root {
  --bg: #0e0e0e;
  --bg2: #161616;
  --bg3: #1e1e1e;
  --bg4: #262626;
  --border: #2e2e2e;
  --border2: #3a3a3a;
  --text: #f0ede8;
  --text2: #a0a09a;
  --text3: #666660;
  --accent: #e8f040;
  --accent2: #c4cc28;
  --role-copy: #9b7ee8;
  --role-pm: #3dbf96;
  --role-data: #e07850;
  --danger: #e05555;
  --success: #3dbf96;
  --radius: 6px;
  --font: Helvetica, Arial, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
  --font-size: 1rem;
  font-size: var(--font-size);
}

:root[data-theme="light"] {
  --bg: #f4f4f0;
  --bg2: #ffffff;
  --bg3: #ebebeb;
  --bg4: #e0e0e0;
  --border: #d0d0cc;
  --border2: #b8b8b4;
  --text: #1a1a18;
  --text2: #5a5a54;
  --text3: #9a9a94;
  --accent: #4a6600;
  --accent2: #3a5000;
}

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

html { height: 100%; }
body { min-height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: var(--font-size); line-height: 1.5; transition: background 0.3s ease; }

.screen { display: none; height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* Login */
.login-wrap {
  background: var(--bg4);
  border: 1px solid var(--border2);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  min-height: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.79rem;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 3rem;
}
.brand-dot {
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
}
.login-portal-name {
  font-size: 3.5rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--text);
  margin-bottom: 1rem;
}
.login-title {
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--text2);
  margin-bottom: 0.5rem;
}
.login-sub { color: var(--text2); margin-bottom: 2.5rem; }

.role-cards { display: flex; flex-direction: column; gap: 12px; }

.role-card {
  
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.role-card:hover { background: var(--bg3); border-color: var(--border2); }
.role-card:hover .role-arrow { opacity: 1; transform: translateX(0); }

.role-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.role-card-info { flex: 1; }
.role-card-name { font-weight: 700; font-size: 1rem; }
.role-card-desc { color: var(--text2); font-size: 0.86rem; margin-top: 2px; }
.role-arrow { color: var(--text3); opacity: 0; transform: translateX(-4px); transition: all 0.15s; }

/* Topbar */
.topbar {
  height: 52px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  flex-shrink: 0;
  gap: 1rem;
  position: relative;
}
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; flex: 1; }
.topbar-brand { font-weight: 700; font-size: 0.85rem; white-space: nowrap; }
.topbar-sep { color: var(--text3); flex-shrink: 0; }
.topbar-role { font-family: var(--font-mono); font-size: 0.86rem; color: var(--text2); }

/* Hamburger */
.hamburger { display: none; flex-direction: column; gap: 5px; background: none; border: none; cursor: pointer; padding: 6px; flex-shrink: 0; }
.hamburger span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: all 0.2s; }
.hamburger-menu { position: absolute; top: 52px; right: 0; width: 220px; background: var(--bg2); border: 1px solid var(--border); border-top: none; border-radius: 0 0 8px 8px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
.hamburger-menu.hidden { display: none; }
.hamburger-item { display: block; width: 100%; text-align: left; padding: 12px 16px; background: none; border: none; border-bottom: 1px solid var(--border); color: var(--text); font-size: 0.93rem; cursor: pointer; }
.hamburger-item:hover { background: var(--bg3); }
.hamburger-item:last-child { border-bottom: none; }

@media (max-width: 1400px) {
  .topbar-right { display: none !important; }
  .hamburger { display: flex; }
}
@media (min-width: 1401px) and (max-width: 1700px) {
  .topbar-brand, .topbar-brand + .topbar-sep { display: none; }
}
@media (max-width: 600px) {
  .topbar-brand, .topbar-brand + .topbar-sep, .brand-dot { display: none; }
}
.role-switcher {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-family: var(--font);
  font-size: 0.93rem;
  font-weight: 600;
  padding: 4px 28px 4px 10px;
  cursor: pointer;
  outline: none;
  appearance: auto;
  transition: border-color 0.12s;
}
.role-switcher:hover { border-color: var(--border2); }
.role-switcher option { background: var(--bg2); color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Layout */
.layout { display: flex; flex: 1; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: 300px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  background: var(--bg2);
  overflow: hidden;
}
.sidebar-header { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }

.search-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.93rem;
  outline: none;
}
.search-input:focus { border-color: var(--border2); }
.search-input::placeholder { color: var(--text3); }

.filter-row { display: flex; gap: 6px; }
.filter-btn {
  flex: 1;
  background: #000;
  border: 1px solid #000;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font);
  font-size: 0.86rem;
  padding: 5px 8px;
  cursor: pointer;
  transition: all 0.12s;
}
.filter-btn:hover { background: #222; border-color: #222; }
.filter-btn.active { background: #333; border-color: #333; color: #fff; }

.product-list { flex: 1; overflow-y: auto; padding: 8px; }

.product-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.12s;
  margin-bottom: 4px;
}
.product-item:hover { background: var(--bg3); }
.product-item.active { background: var(--bg3); border-color: var(--border2); }

.product-item-title {
  font-weight: 600;
  font-size: 0.93rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}
.product-item-meta {
  font-family: var(--font-mono);
  font-size: 0.79rem;
  color: var(--text3);
  margin-bottom: 6px;
}
.completion-bar {
  height: 3px;
  background: var(--bg4);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 6px;
}
.completion-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s;
}

/* Content area */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--bg);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60%;
  color: var(--text3);
  gap: 1rem;
}
.empty-icon { font-size: 3rem; opacity: 0.3; }

.hidden { display: none !important; }

/* Product detail */
.product-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}
.product-handle {
  font-family: var(--font-mono);
  font-size: 0.79rem;
  color: var(--text3);
  margin-bottom: 4px;
}
.product-title-h { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.product-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

.completion-badges { display: flex; gap: 8px; margin-bottom: 2rem; flex-wrap: wrap; }
.comp-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 100px;
  border: 1px solid var(--border);
  font-size: 0.86rem;
  background: var(--bg2);
}
.comp-badge-dot { width: 8px; height: 8px; border-radius: 50%; }
.comp-badge-pct { font-family: var(--font-mono); font-weight: 500; }
.comp-badge:hover { border-color: var(--border2); background: var(--bg3); }
.comp-badge-active { border-width: 1.5px !important; }

.field-section { margin-bottom: 2rem; }
.field-section-title {
  font-size: 0.79rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text3);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fields-grid.wide { grid-template-columns: 1fr; }

.field-group { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 0.79rem; color: var(--text2); font-family: var(--font-mono); }
.field-mf-key { font-size: 0.68rem; color: var(--text3); font-family: var(--font-mono); opacity: 0.7; }
.field-input {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.93rem;
  outline: none;
  transition: border-color 0.12s;
  width: 100%;
}
.field-input:focus { border-color: var(--accent2); }
.field-input.filled { border-color: var(--border2); }
textarea.field-input { resize: vertical; min-height: 80px; }

/* Variants table */
.variants-section { margin-bottom: 2rem; }
.variants-table-wrap { overflow-x: auto; }
.variants-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.variants-table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.71rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 6px 8px;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid var(--border);
  white-space: nowrap;
}
.variants-table th:last-child { border-right: none; }
.variants-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); vertical-align: top; }
.variants-table td:last-child { border-right: none; }
.variants-table tr:last-child td { border-bottom: none; }
.variants-table td input {
  background: transparent;
  border: none;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.86rem;
  width: 100%;
  outline: none;
  padding: 2px 0;
}
.variants-table td input:focus { color: var(--accent); }
.sku-cell { font-family: var(--font-mono); color: var(--text2); }

/* Buttons */
.btn-primary {
  background: #000;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.93rem;
  cursor: pointer;
  transition: background 0.12s;
}
.btn-primary:hover { background: #222; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-outline {
  background: #000;
  color: #fff;
  border: 1px solid #000;
  border-radius: var(--radius);
  padding: 7px 14px;
  font-family: var(--font);
  font-size: 0.93rem;
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-outline:hover { background: #222; border-color: #222; }

.btn-ghost {
  background: #000;
  border: none;
  color: #fff;
  font-family: var(--font);
  font-size: 0.93rem;
  cursor: pointer;
  padding: 7px 10px;
  border-radius: var(--radius);
  transition: background 0.12s;
}
.btn-ghost:hover { background: #222; }

.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-family: inherit; font-size: inherit; text-decoration: underline; }

/* Save bar */
.save-bar {
  position: sticky;
  bottom: 0;
  background: #ffffff;
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 2rem;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}
.save-bar-hint { font-size: 0.86rem; color: var(--text3); flex: 1; }

/* Settings bar */
.settings-bar {
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-label {
  font-size: 0.79rem;
  color: var(--text3);
  white-space: nowrap;
}
.settings-select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-family: var(--font);
  font-size: 0.86rem;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}
.settings-select:hover { border-color: var(--border2); }

/* Theme toggle */
.theme-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text2);
  font-size: 1rem;
  padding: 5px 8px;
  cursor: pointer;
  transition: all 0.12s;
  line-height: 1;
}
.theme-toggle:hover { border-color: var(--border2); color: var(--text); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  width: 90%;
  max-width: 480px;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 1.14rem; }
.modal-body { padding: 1.5rem; }
.modal-desc { color: var(--text2); font-size: 0.93rem; margin-bottom: 1.25rem; line-height: 1.6; }

.drop-zone {
  border: 1.5px dashed var(--border2);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text2);
  cursor: pointer;
  transition: border-color 0.15s;
}
.drop-zone:hover, .drop-zone.drag-over { border-color: var(--accent); }
.drop-icon { font-size: 2rem; margin-bottom: 0.75rem; }
.drop-hint { font-size: 0.79rem; color: var(--text3); margin-top: 6px; }

.progress-bar { height: 4px; background: var(--bg3); border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.progress-fill { height: 100%; background: var(--accent); transition: width 0.3s; border-radius: 2px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 0.93rem;
  z-index: 200;
  transition: opacity 0.3s;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

.loading { color: var(--text3); text-align: center; padding: 2rem; font-size: 0.93rem; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.brand-switcher {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.93rem;
  font-weight: 700;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}
.brand-switcher:hover { border-color: var(--border2); }
.brand-switcher option { background: var(--bg2); color: var(--text); }

.season-switcher {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.86rem;
  font-weight: 600;
  padding: 4px 8px;
  cursor: pointer;
  outline: none;
}
.season-switcher:hover { border-color: var(--border2); }
.season-switcher option { background: var(--bg2); color: var(--text); }

.carry-over-badge {
  display: inline-block;
  font-size: 0.71rem;
  font-family: var(--font-mono);
  color: var(--text3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

.field-input.carry-over {
  border-color: var(--border);
  opacity: 0.75;
  font-style: italic;
}

.modal-season-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}


@keyframes gradientMove {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
body.auth-bg {
  position: relative;
  background: #1a1a1a;
}
body.auth-bg::before {
  display: none;
}
body.auth-bg #screen-auth,
body.auth-bg #screen-login {
  position: relative;
  z-index: 1;
}
.login-wrap { max-width: 480px !important; text-align: center !important; }
.login-portal-name { font-size: 3.2rem !important; white-space: nowrap !important; }
.login-emoji { display: block; font-size: 3.5rem !important; margin-bottom: 8px; }
#screen-auth, #screen-login { display: none; }
#screen-auth.active, #screen-login.active {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
}

body.auth-bg::before { animation-duration: 12s !important; }
