:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f7f7f7;
  --ink: #242424;
  --muted: #898989;
  --line: rgba(34, 42, 53, 0.1);
  --ring: rgba(34, 42, 53, 0.08);
  --focus: rgba(59, 130, 246, 0.45);
  --danger: #b42318;
  --warning: #9a6700;
  --info: #175cd3;
  --ok: #067647;
  --shadow: rgba(19, 19, 22, 0.7) 0 1px 5px -4px, rgba(34, 42, 53, 0.08) 0 0 0 1px, rgba(34, 42, 53, 0.05) 0 4px 8px 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

a {
  color: var(--ink);
  text-underline-offset: 3px;
}

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

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
}

.mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  font-size: 14px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page {
  width: min(1200px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0 28px;
  flex: 1;
}

.login-page {
  width: min(980px, calc(100vw - 32px));
  display: grid;
  grid-template-columns: 1fr 390px;
  align-items: center;
  gap: 48px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

h1,
h2,
h3 {
  margin: 0;
  color: var(--ink);
  font-weight: 750;
  line-height: 1.1;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  font-size: 28px;
}

h3 {
  font-size: 17px;
}

.lead {
  max-width: 620px;
  margin: 18px 0 0;
  color: #555;
  font-size: 17px;
  line-height: 1.6;
}

.weekly-report-lead {
  max-width: none;
  white-space: nowrap;
}

.report-title-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.report-title-meta {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.admin-users-page {
  width: calc(100vw - 224px - 32px);
  max-width: 1400px;
}

.admin-users-panel {
  margin-top: 24px;
}

.admin-users-scroll {
  overflow-x: auto;
}

.admin-users-table {
  min-width: 920px;
}

.admin-users-table th,
.admin-users-table td {
  text-align: center;
  vertical-align: middle;
}

.admin-users-table th:nth-child(1),
.admin-users-table th:nth-child(2),
.admin-users-table td:nth-child(1),
.admin-users-table td:nth-child(2) {
  text-align: left;
}

.permission-toggle {
  width: 18px;
  height: 18px;
  accent-color: var(--ink);
}

.user-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.btn-danger {
  border-color: rgba(180, 35, 24, 0.24);
  color: var(--danger);
}

.btn-danger:hover {
  background: #fff1f0;
}

.access-denied {
  max-width: 640px;
  margin: 32px auto;
}

.panel,
.card,
.metric {
  background: var(--panel);
  box-shadow: var(--shadow);
  border-radius: 12px;
}

.panel {
  padding: 22px;
}

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

.field {
  display: grid;
  gap: 7px;
}

label {
  color: #444;
  font-size: 13px;
  font-weight: 650;
}

input,
select {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font: inherit;
  outline: none;
}

.asin-list {
  display: grid;
  gap: 10px;
}

.asin-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 72px;
  align-items: center;
  gap: 10px;
}

.role-pill {
  display: inline-grid;
  place-items: center;
  height: 32px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #344054;
}

.role-pill.own {
  color: #175cd3;
  background: #eff8ff;
}

.role-pill.competitor {
  color: #667085;
  background: #f9fafb;
}

.asin-remove {
  box-shadow: none;
  border: 1px solid var(--line);
}

.add-asin {
  justify-self: start;
  margin-top: 2px;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

input:focus,
select:focus,
button:focus-visible {
  box-shadow: 0 0 0 4px var(--focus);
  border-color: #98a2b3;
}

button {
  height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 15px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  color: #fff;
  background: var(--ink);
  box-shadow: rgba(255, 255, 255, 0.15) 0 2px 0 inset;
}

.btn-ghost {
  color: var(--ink);
  background: #fff;
  box-shadow: var(--shadow);
}

.btn-link {
  padding: 0;
  height: auto;
  color: var(--ink);
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 10px;
  background: var(--panel-soft);
}

.tab {
  background: transparent;
  color: #555;
}

.tab.active {
  color: var(--ink);
  background: #fff;
  box-shadow: rgba(34, 42, 53, 0.1) 0 0 0 1px;
}

.message {
  display: none;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: #444;
  font-size: 13px;
  line-height: 1.45;
}

.message.show {
  display: block;
}

.message.error {
  color: var(--danger);
  background: #fff3f2;
}

.message.success {
  color: var(--ok);
  background: #ecfdf3;
}

.tool-grid {
  display: grid;
  gap: 18px;
}

#weeklyReportList {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.weekly-report-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
}

#weeklyReportList .tool-card {
  display: grid;
  width: 100%;
  gap: 6px;
  padding: 14px 16px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

#weeklyReportList .tool-card:hover {
  border-color: rgba(36, 36, 36, 0.28);
  box-shadow: 0 8px 22px rgba(34, 42, 53, 0.08);
}

#weeklyReportList .tool-card span {
  color: var(--muted);
  font-size: 14px;
}

.weekly-delete-button {
  min-width: 72px;
  align-self: stretch;
}

.task-form {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px 18px;
  align-items: start;
}

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

.task-form .btn-primary {
  grid-column: 1 / -1;
  justify-self: start;
  min-width: 140px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.muted {
  color: var(--muted);
}

.table-shell {
  overflow: auto;
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: #fff;
}

table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  color: #555;
  background: #f8f8f8;
  font-size: 12px;
  font-weight: 750;
}

tr:last-child td {
  border-bottom: 0;
}

.status,
.priority {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 9999px;
  background: #f3f4f6;
  color: #444;
  font-size: 12px;
  font-weight: 700;
}

.status::before,
.priority::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: currentColor;
}

.status.done,
.priority.p1 {
  color: var(--ok);
  background: #ecfdf3;
}

.status.running,
.priority.p2 {
  color: var(--info);
  background: #eff8ff;
}

.status.failed,
.priority.p0 {
  color: var(--danger);
  background: #fff3f2;
}

.priority.p3 {
  color: #667085;
  background: #f2f4f7;
}

.priority.p1 {
  color: var(--warning);
  background: #fffaeb;
}

.empty {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.report-frame {
  width: 100%;
  height: calc(100vh - 144px);
  min-height: 620px;
  border: 0;
  border-radius: 12px;
  box-shadow: var(--shadow);
  background: #fff;
}

.report-heading {
  min-width: 0;
}

.report-module-nav {
  display: flex;
  gap: 8px;
  width: 100%;
  margin: 0 0 14px;
  padding: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  scrollbar-width: thin;
}

.report-module-nav[hidden] {
  display: none;
}

.report-module-tab {
  flex: 1 0 auto;
  min-width: 150px;
  height: auto;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: #344054;
  background: transparent;
  line-height: 1.3;
  white-space: nowrap;
}

.report-module-tab:hover {
  background: #fff;
}

.report-module-tab.active {
  border-color: #c7d7fe;
  color: #155eef;
  background: #eef4ff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.report-module-tab.disabled {
  color: #98a2b3;
}

.report-module-tab span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
}

body.market-report-fullscreen {
  overflow: hidden;
}

.market-report-fullscreen .shell.with-sidebar {
  min-height: 100vh;
  padding-left: 224px;
}

.market-report-fullscreen .footer,
.market-report-fullscreen main > section,
.market-report-fullscreen #marketReportListCard {
  display: none;
}

.market-report-fullscreen .page {
  display: block;
  width: calc(100vw - 224px);
  max-width: none;
  height: 100vh;
  margin: 0;
  padding: 0;
}

.market-report-fullscreen #marketReportMessage {
  position: fixed;
  z-index: 30;
  top: 80px;
  left: calc(50% + 112px);
  width: auto;
  max-width: calc(100vw - 256px);
  transform: translateX(-50%);
}

.market-report-fullscreen #marketReportFrame {
  display: block;
  width: 100%;
  height: 100vh;
  min-height: 100vh;
  border-radius: 0;
  box-shadow: none;
}

.with-sidebar .report-page {
  width: calc(100vw - 224px - 32px);
  max-width: none;
}

.footer {
  padding: 18px 28px;
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
  gap: 8px;
}

@media (max-width: 860px) {
  .topbar {
    padding: 0 16px;
  }

  .login-page {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .task-form {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-actions {
    gap: 6px;
  }
}

.weekly-admin-panel {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #f8fafc;
}

[hidden] {
  display: none !important;
}

.with-sidebar {
  padding-left: 224px;
}

.side-nav {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: 224px;
  height: 100vh;
  padding: 22px 16px;
  border-right: 1px solid var(--line);
  background: #ffffff;
  box-shadow: 10px 0 30px rgba(15, 23, 42, 0.04);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 22px;
  font-size: 18px;
  font-weight: 800;
}

.side-links {
  display: grid;
  gap: 8px;
}

.side-link {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border-radius: 14px;
  color: #344054;
  text-decoration: none;
  border: 1px solid transparent;
}

.side-link span {
  font-weight: 760;
}

.side-link small {
  color: var(--muted);
  font-size: 11px;
}

.side-link:hover,
.side-link.active {
  color: var(--ink);
  background: #f8fafc;
  border-color: var(--line);
}

.side-link.active {
  box-shadow: inset 3px 0 0 var(--ink);
}

.side-account {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-top: auto;
  padding: 16px 8px 0;
  border-top: 1px solid var(--line);
}

.side-account-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #344054;
  background: #e9f7ef;
  font-size: 12px;
  font-weight: 800;
}

.side-account-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.side-account-copy #userEmail {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.side-account-copy small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-logout {
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.side-logout:hover {
  color: var(--ink);
}

@media (max-width: 860px) {
  .with-sidebar {
    padding-left: 0;
  }

  .with-sidebar .report-page {
    width: calc(100vw - 32px);
  }

  .report-module-tab {
    flex-basis: 170px;
  }

  .side-nav {
    position: static;
    width: auto;
    height: auto;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: none;
  }

  .side-brand {
    padding: 0 0 10px;
  }

  .side-links {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .side-link {
    padding: 10px 12px;
  }

  .side-account {
    margin-top: 12px;
    padding: 12px 0 0;
  }

  .market-report-fullscreen {
    overflow: auto;
  }

  .market-report-fullscreen .shell.with-sidebar {
    padding-left: 0;
  }

  .market-report-fullscreen .side-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .market-report-fullscreen .page {
    width: 100vw;
    height: calc(100vh - 154px);
  }

  .market-report-fullscreen #marketReportMessage {
    left: 50%;
    max-width: calc(100vw - 32px);
  }

  .market-report-fullscreen #marketReportFrame {
    height: calc(100vh - 154px);
    min-height: calc(100vh - 154px);
  }
}
