:root {
  --seafoam: #90e0da;
  --seafoam-50: #effbf9;
  --seafoam-100: #d9f4f1;
  --seafoam-200: #b9ebe6;
  --seafoam-500: #32aaa4;
  --seafoam-700: #146c69;
  --ink: #123235;
  --muted: #607477;
  --line: #c8e3df;
  --paper: #edf8f6;
  --surface: #fcfffc;
  --surface-strong: #f1fbf8;
  --nav: #0a3032;
  --nav-2: #15484a;
  --blue: #168a92;
  --green: #2f8567;
  --red: #c65345;
  --amber: #bd7d25;
  --gold: #e9c756;
  --shadow: 0 14px 34px rgba(18, 50, 53, 0.12);
  --shadow-tight: 0 8px 18px rgba(18, 50, 53, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(20, 108, 105, 0.07) 1px, transparent 1px),
    linear-gradient(180deg, rgba(20, 108, 105, 0.07) 1px, transparent 1px),
    linear-gradient(135deg, rgba(144, 224, 218, 0.62), transparent 28rem),
    linear-gradient(315deg, rgba(233, 199, 86, 0.14), transparent 22rem),
    var(--paper);
  background-size: 34px 34px, 34px 34px, 100% 100%;
  color: var(--ink);
  font-family: "Microsoft JhengHei", "Noto Sans TC", "Aptos", "Segoe UI", Tahoma, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 14px;
  background:
    linear-gradient(180deg, rgba(144, 224, 218, 0.2), transparent 18rem),
    linear-gradient(180deg, var(--nav), #07181b);
  color: #eef7f4;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand-lockup {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 4px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand-mark {
  width: 42px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: linear-gradient(135deg, var(--seafoam), #d7fbf7);
  color: #10292f;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.brand-name {
  font-size: 20px;
  font-weight: 800;
}

.brand-subtitle,
.data-stamp span {
  color: #aee1dc;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-item {
  color: #dbe9e6;
  text-decoration: none;
  padding: 11px 12px;
  border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  font-weight: 700;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: var(--gold);
  color: #ffffff;
  transform: translateX(2px);
}

.data-stamp {
  margin-top: auto;
  padding: 13px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 4px;
}

.workspace {
  padding: 28px clamp(20px, 3vw, 42px) 42px;
  display: grid;
  gap: 18px;
  max-width: 1640px;
  width: 100%;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 22px;
  padding: 8px 0 2px;
}

.colour-filter {
  display: grid;
  gap: 7px;
  min-width: 280px;
}

.colour-filter > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.colour-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-control {
  display: grid;
  gap: 7px;
  justify-items: end;
  min-width: 210px;
}

.sync-button {
  min-height: 36px;
  border: 1px solid var(--nav);
  background: var(--nav);
  color: #ffffff;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 900;
  box-shadow: var(--shadow-tight);
}

.sync-button:hover,
.sync-button:focus-visible {
  background: var(--seafoam-700);
  outline: none;
}

.sync-button[disabled] {
  cursor: wait;
  opacity: 0.68;
}

#syncStatus {
  max-width: 280px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  text-align: right;
}

#syncStatus.ok {
  color: var(--seafoam-700);
}

#syncStatus.error {
  color: var(--red);
}

.colour-chip {
  min-height: 36px;
  border: 1px solid var(--line);
  background: rgba(252, 255, 252, 0.9);
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 900;
}

.colour-chip::before {
  content: "";
  display: inline-block;
  width: 10px;
  aspect-ratio: 1;
  margin-right: 7px;
  border-radius: 50%;
  border: 1px solid rgba(18, 50, 53, 0.2);
  background: var(--chip-colour, var(--seafoam));
}

.colour-chip.active {
  background: var(--nav);
  border-color: var(--nav);
  color: #fff;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 900px;
  font-size: clamp(30px, 4.2vw, 56px);
  line-height: 1.04;
  font-weight: 900;
  text-wrap: balance;
}

h2 {
  font-size: 18px;
  font-weight: 900;
}

.section-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.data-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.colour-scope-note {
  margin: -6px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(252, 255, 252, 0.78);
}

.search-field {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  height: 40px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  border-radius: 6px;
  outline: none;
}

input {
  width: min(320px, 70vw);
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(144, 224, 218, 0.34);
}

.keyword-tools {
  display: flex;
  align-items: end;
  gap: 10px;
  padding: 12px;
  margin: 0 0 12px;
  border: 1px solid var(--line);
  background: var(--seafoam-50);
}

.keyword-search {
  flex: 1;
}

.keyword-search input {
  width: 100%;
}

.clear-button {
  height: 40px;
  border: 1px solid var(--line);
  background: #fffdf7;
  color: var(--seafoam-700);
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.clear-button:hover {
  border-color: var(--blue);
  color: var(--blue);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(175px, 1fr));
  gap: 12px;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
  gap: 14px;
}

.kpi-card,
.panel,
.inventory-card {
  background: rgba(252, 255, 252, 0.97);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.kpi-card {
  --accent: var(--blue);
  --accent-soft: rgba(22, 138, 146, 0.1);
  position: relative;
  min-height: 148px;
  padding: 17px 16px 14px;
  border-top: 0;
  border-left: 5px solid var(--accent);
  background:
    linear-gradient(135deg, var(--accent-soft), rgba(252, 255, 252, 0) 46%),
    rgba(252, 255, 252, 0.97);
  display: grid;
  grid-template-rows: 20px 48px 22px minmax(28px, auto);
  align-content: start;
  gap: 5px;
  overflow: hidden;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(20, 34, 37, 0.16);
}

.accent-red {
  --accent: var(--red);
  --accent-soft: rgba(198, 83, 69, 0.1);
}

.accent-green {
  --accent: var(--green);
  --accent-soft: rgba(47, 133, 103, 0.1);
}

.accent-amber {
  --accent: var(--amber);
  --accent-soft: rgba(189, 125, 37, 0.12);
}

.accent-blue {
  --accent: var(--blue);
  --accent-soft: rgba(22, 138, 146, 0.1);
}

.kpi-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-card strong {
  display: flex;
  align-items: end;
  color: color-mix(in srgb, var(--accent) 35%, var(--ink));
  font-size: 31px;
  line-height: 0.95;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.kpi-card small {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.kpi-card em {
  display: block;
  color: var(--seafoam-700);
  font-size: 10.5px;
  font-style: normal;
  line-height: 1.28;
  opacity: 0.72;
  max-width: 18ch;
}

.metric-guide {
  background: rgba(252, 255, 252, 0.74);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-tight);
}

.metric-guide details {
  padding: 0;
}

.metric-guide summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  cursor: pointer;
  list-style: none;
}

.metric-guide summary::-webkit-details-marker {
  display: none;
}

.metric-guide summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 26px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--seafoam-100);
  color: var(--seafoam-700);
  font-weight: 900;
}

.metric-guide details[open] summary::after {
  content: "-";
}

.metric-guide summary span {
  font-weight: 900;
}

.metric-guide summary small {
  color: var(--muted);
  margin-left: auto;
}

.metric-guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 0 16px 16px;
}

.metric-guide-grid article {
  border: 1px solid var(--line);
  background: var(--seafoam-50);
  padding: 12px;
}

.metric-guide-grid strong {
  display: block;
  margin-bottom: 5px;
}

.metric-guide-grid p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.panel {
  padding: 18px;
  min-width: 0;
  border-radius: 2px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(216, 221, 212, 0.78);
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  border: 1px solid var(--line);
  background: var(--seafoam-100);
  color: var(--seafoam-700);
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.bar-stack {
  display: grid;
  gap: 11px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(140px, 260px) minmax(0, 1fr) minmax(112px, 190px);
  gap: 14px;
  align-items: center;
}

.bar-label {
  min-width: 0;
  font-weight: 850;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-track {
  height: 14px;
  border: 1px solid #b9ded9;
  background: #e5f7f4;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(20, 34, 37, 0.08);
}

.bar-fill {
  height: 100%;
  width: var(--w);
  background: linear-gradient(90deg, var(--seafoam-700), var(--seafoam));
  box-shadow: 10px 0 22px rgba(144, 224, 218, 0.34);
}

.bar-value {
  color: var(--muted);
  text-align: right;
  font-size: 12px;
}

.insight-list,
.rank-list {
  display: grid;
  gap: 10px;
}

.insight,
.rank-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, var(--surface-strong));
  box-shadow: var(--shadow-tight);
}

.insight strong,
.rank-item strong {
  font-size: 14px;
}

.insight p,
.rank-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.rank-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rank-meta span {
  background: var(--seafoam-100);
  color: var(--seafoam-700);
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 12px;
}

.business-title {
  display: grid;
  gap: 3px;
}

.business-title span {
  color: var(--blue);
  font-weight: 900;
}

.monthly-row .bar-fill {
  background: linear-gradient(90deg, var(--amber), #efc65f);
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.segment {
  height: 36px;
  padding: 0 12px;
  border: 0;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-weight: 850;
}

.segment.active {
  background: var(--nav);
  color: #fff;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.count-pill {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: var(--seafoam-100);
  color: var(--seafoam-700);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.chip-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 14px;
  scrollbar-width: thin;
}

.filter-chip {
  min-height: 34px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--seafoam-700);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 800;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.filter-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(144, 224, 218, 0.95);
}

.filter-chip span {
  color: var(--muted);
  margin-left: 4px;
  font-weight: 700;
}

.filter-chip.active {
  background: var(--nav);
  border-color: var(--nav);
  color: #fff;
}

.filter-chip.active span {
  color: #cfefec;
}

.table-panel {
  padding-bottom: 6px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  max-height: 560px;
  box-shadow: var(--shadow-tight);
}

table {
  width: max-content;
  min-width: 0;
  border-collapse: collapse;
  background: var(--surface);
  table-layout: fixed;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e0e5e2;
  text-align: left;
  font-size: 13px;
  vertical-align: top;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--nav);
  color: #ffffff;
  z-index: 1;
  padding: 0;
  font-size: 12px;
  user-select: none;
}

.sort-button {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 18px 10px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-weight: 900;
  text-align: left;
}

.sort-button:hover,
.sort-button:focus-visible {
  background: rgba(144, 224, 218, 0.12);
  outline: none;
}

.sort-indicator {
  min-width: 12px;
  color: var(--seafoam);
  font-size: 10px;
  text-align: right;
}

.column-resizer {
  position: absolute;
  top: 0;
  right: -4px;
  z-index: 2;
  width: 9px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

.column-resizer::after {
  content: "";
  position: absolute;
  top: 9px;
  bottom: 9px;
  left: 4px;
  width: 1px;
  background: rgba(255, 255, 255, 0.28);
}

.column-resizer:hover::after,
.is-resizing-column .column-resizer::after {
  background: var(--seafoam);
}

.is-resizing-column {
  cursor: col-resize;
  user-select: none;
}

tbody tr:hover {
  background: var(--seafoam-50);
}

tbody tr:nth-child(even) {
  background: #f7fdfa;
}

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

.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.action-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 220px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--seafoam-100);
  color: var(--seafoam-700);
  font-weight: 800;
  font-size: 12px;
}

.action-badge.warning {
  background: #fff0da;
  color: #75470c;
}

.action-badge.danger {
  background: #fee7e2;
  color: #84251d;
}

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

.asin-card {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, var(--seafoam-50));
  padding: 14px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow-tight);
}

.asin-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.3;
}

.asin-code {
  color: var(--blue);
  font-weight: 900;
}

.funnel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.funnel div {
  background: var(--seafoam-50);
  padding: 10px;
  display: grid;
  gap: 4px;
  border-left: 3px solid rgba(144, 224, 218, 0.95);
}

.funnel span {
  color: var(--muted);
  font-size: 11px;
}

.funnel strong {
  font-size: 16px;
}

.inventory-panel {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  border-left: 6px solid var(--amber);
  background: linear-gradient(90deg, rgba(144, 224, 218, 0.16), rgba(252, 255, 252, 0.98) 36%);
}

.inventory-panel p {
  max-width: 760px;
  color: var(--muted);
  line-height: 1.55;
}

.inventory-card {
  min-width: 280px;
  padding: 16px;
  display: grid;
  gap: 6px;
  background: #fbfffc;
}

.inventory-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow: auto;
  }

  .nav-list {
    display: flex;
  }

  .data-stamp {
    margin: 0 0 0 auto;
    min-width: 160px;
  }

  .kpi-grid,
  .panel-grid,
  .metric-guide-grid,
  .asin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .workspace {
    padding: 16px;
  }

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

  .colour-filter,
  .sync-control {
    min-width: 0;
  }

  .sync-control {
    justify-items: stretch;
  }

  #syncStatus {
    max-width: none;
    text-align: left;
  }

  .keyword-tools,
  .colour-options,
  .kpi-grid,
  .panel-grid,
  .metric-guide-grid,
  .asin-grid,
  .funnel {
    grid-template-columns: 1fr;
    display: grid;
  }

  .sidebar {
    display: grid;
  }

  .data-stamp {
    margin: 0;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bar-value {
    text-align: left;
  }
}
