:root {
  color-scheme: light;
  --bg: #eef2f4;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #60707a;
  --line: #d8e0e5;
  --accent: #ffe000;
  --accent-strong: #2d3277;
  --good: #147a4f;
  --bad: #b42318;
  --shadow: 0 18px 45px rgba(24, 35, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f7d917 0 245px, var(--bg) 245px 100%);
  color: var(--ink);
  font-family: Inter, Segoe UI, Arial, sans-serif;
}

body.theme-shoppe {
  background: linear-gradient(180deg, #f58220 0 245px, var(--bg) 245px 100%);
}

body.theme-shoppe #shoppe h1 {
  color: #ffffff;
}

body.theme-tiktok {
  background: linear-gradient(180deg, #111827 0 245px, var(--bg) 245px 100%);
}

body.theme-tiktok #tiktok-shop h1,
body.theme-tiktok #tiktok-shop .eyebrow {
  color: #ffffff;
}

button,
input,
select {
  font: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 268px;
  border-right: 1px solid rgba(216, 224, 229, 0.78);
  background: #ffffff;
  box-shadow: 12px 0 35px rgba(24, 35, 44, 0.08);
  padding: 22px 16px;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 92px;
  margin-bottom: 22px;
  padding: 0 4px;
}

.brand-logo {
  display: block;
  width: min(210px, 100%);
  height: auto;
}

.main-nav {
  display: grid;
  gap: 8px;
}

.nav-link {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border-radius: 8px;
  color: #43525c;
  padding: 7px 10px;
  text-decoration: none;
  font-weight: 800;
}

.nav-link.active,
.nav-link:hover {
  background: #fff5da;
  color: var(--accent-strong);
}

.logout-link {
  margin-top: 14px;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid rgba(216, 224, 229, 0.9);
  overflow: hidden;
}

.nav-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nav-link.active .nav-icon,
.nav-link:hover .nav-icon {
  border-color: rgba(45, 50, 119, 0.28);
}

.stock-icon {
  background: #eaf7ef;
  color: var(--good);
  font-size: 0.72rem;
  font-weight: 900;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 0 calc(268px + max(24px, (100vw - 268px - 1180px) / 2));
  padding: 34px 0 48px;
}

.calculator-page {
  display: none;
}

.calculator-page.active {
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #151a20;
  font-size: clamp(2rem, 4vw, 3.45rem);
  line-height: 1.03;
  letter-spacing: 0;
}

.ghost-button {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid rgba(45, 50, 119, 0.28);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 800;
}

.save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  min-width: 150px;
  border: 0;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #ffffff;
  cursor: pointer;
  font-weight: 850;
}

.button-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1.1rem;
  line-height: 1;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 22px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 22px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field-wide {
  grid-column: 1 / -1;
}

.field span,
.result-card span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid #cbd6dc;
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 0 13px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 3px rgba(45, 50, 119, 0.12);
}

.results {
  display: grid;
  gap: 14px;
  padding: 18px;
  position: sticky;
  top: 18px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.result-card {
  display: grid;
  gap: 9px;
  min-height: 98px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 15px;
}

.result-card strong {
  color: var(--ink);
  font-size: 1.34rem;
  line-height: 1.1;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.result-card.primary {
  min-height: 130px;
  border-color: rgba(45, 50, 119, 0.24);
  background: #252b6f;
}

.result-card.primary span,
.result-card.primary strong {
  color: #ffffff;
}

.result-card.primary strong {
  font-size: clamp(2rem, 4vw, 3.2rem);
}

.positive {
  color: var(--good) !important;
}

.negative {
  color: var(--bad) !important;
}

.saved-panel {
  margin-top: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.saved-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

h2 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0;
}

.search-field {
  display: grid;
  gap: 7px;
  width: min(360px, 100%);
}

.search-field span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.saved-tools {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 12px;
  width: min(560px, 100%);
}

.export-actions {
  display: flex;
  gap: 8px;
  padding-bottom: 1px;
}

.export-button {
  min-height: 48px;
  border: 1px solid rgba(45, 50, 119, 0.22);
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 850;
  padding: 0 14px;
}

.export-button:hover {
  background: #fff5da;
}

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

table {
  width: 100%;
  min-width: 1260px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  background: #f5f8fa;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

td {
  color: var(--ink);
  font-size: 0.92rem;
}

td.product-cell {
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions-cell {
  display: flex;
  gap: 8px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}

.icon-button.delete {
  color: var(--bad);
}

.empty-state {
  margin: 0;
  padding: 28px 22px;
  color: var(--muted);
  text-align: center;
}

.placeholder-card {
  padding: 26px;
}

.placeholder-card p {
  margin: 8px 0 0;
  color: var(--muted);
}

.comparison-workspace {
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.55fr);
}

.comparison-summary {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.comparison-summary .result-card {
  min-height: 116px;
}

.comparison-table {
  min-width: 720px;
}

.marketplace-name {
  font-weight: 850;
}

.stock-layout {
  display: grid;
  gap: 22px;
}

.stock-form {
  max-width: 760px;
}

.stock-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.stock-card {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 18px;
}

.stock-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.stock-card h2 {
  font-size: 1.08rem;
  overflow-wrap: anywhere;
}

.stock-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stock-metric {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  padding: 12px;
}

.stock-metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.stock-metric strong {
  font-size: 1.12rem;
  overflow-wrap: anywhere;
}

.stock-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)) 40px;
  gap: 8px;
}

.stock-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 850;
}

.stock-button.remove {
  color: #8a4b00;
}

.stock-button.delete {
  color: var(--bad);
  font-size: 1.1rem;
}

.stock-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background: linear-gradient(180deg, #f7d917 0 38%, var(--bg) 38% 100%);
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-logo {
  display: block;
  width: min(260px, 100%);
  height: auto;
  margin: 0 auto 20px;
}

.login-card h1 {
  font-size: 1.7rem;
  text-align: center;
}

.login-subtitle {
  margin: 10px 0 20px;
  color: var(--muted);
  text-align: center;
}

.login-error {
  margin: 0 0 14px;
  border: 1px solid rgba(180, 35, 24, 0.24);
  border-radius: 8px;
  background: #fff4f2;
  color: var(--bad);
  padding: 10px 12px;
  font-weight: 750;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 7px;
}

.login-form span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.login-form .save-button {
  width: 100%;
  margin-top: 4px;
}

@media (max-width: 860px) {
  body {
    background: linear-gradient(180deg, #f7d917 0 340px, var(--bg) 340px 100%);
  }

  body.theme-shoppe {
    background: linear-gradient(180deg, #f58220 0 340px, var(--bg) 340px 100%);
  }

  body.theme-tiktok {
    background: linear-gradient(180deg, #111827 0 340px, var(--bg) 340px 100%);
  }

  .sidebar {
    position: static;
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid rgba(216, 224, 229, 0.78);
    box-shadow: 0 10px 28px rgba(24, 35, 44, 0.08);
  }

  .brand {
    margin-bottom: 16px;
  }

  .main-nav {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

  .nav-link {
    grid-template-columns: 1fr;
    justify-items: center;
    min-height: 78px;
    text-align: center;
    font-size: 0.82rem;
  }

  .shell {
    margin: 0 auto;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

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

  .results {
    position: static;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 22px, 1180px);
    padding-top: 22px;
  }

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

  .main-nav {
    grid-template-columns: 1fr;
  }

  .nav-link {
    grid-template-columns: 34px minmax(0, 1fr);
    justify-items: start;
    min-height: 48px;
    text-align: left;
    font-size: 0.95rem;
  }

  .ghost-button {
    width: 100%;
  }

  .inputs,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .form-actions {
    justify-content: stretch;
  }

  .save-button {
    width: 100%;
  }

  .saved-header {
    align-items: stretch;
    flex-direction: column;
  }

  .stock-list {
    grid-template-columns: 1fr;
  }

  .stock-metrics,
  .stock-actions {
    grid-template-columns: 1fr;
  }

  .saved-tools {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .export-actions {
    padding-bottom: 0;
  }

  .export-button {
    flex: 1;
  }
}
