:root {
  --bg: #f6f0e7;
  --surface: rgba(255, 250, 242, 0.88);
  --surface-strong: rgba(255, 252, 247, 0.96);
  --ink: #1f1c18;
  --muted: #6c6258;
  --line: rgba(77, 55, 27, 0.12);
  --shadow: 0 24px 70px rgba(76, 49, 21, 0.12);
  --success: #147a4d;
  --success-soft: #ddf6e7;
  --warning: #b46b1f;
  --warning-soft: #fff0db;
  --danger: #b9382d;
  --danger-soft: #fee3df;
  --neutral: #607087;
  --neutral-soft: #edf2f8;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #efe8dd 0%, #f5eee4 100%);
}

.page-shell {
  width: min(1180px, calc(100vw - 28px));
  margin: 6px auto;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 22px 72px rgba(73, 47, 18, 0.13);
  background: #f3eee5;
}

.page-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.topbar {
  background: #0f172a;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-logo {
  width: 30px;
  height: 30px;
  background: #1e293b;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: -0.02em;
}

.topbar-name {
  color: #f1f5f9;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.topbar-version {
  font-size: 11px;
  color: #334155;
  margin-left: 2px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-pill {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.topbar-pill.success {
  background: #052e16;
  color: #4ade80;
}

.topbar-pill.warning {
  background: #451a03;
  color: #fbbf24;
}

.topbar-pill.danger {
  background: #450a0a;
  color: #f87171;
}

.topbar-pill.neutral {
  background: #1e293b;
  color: #64748b;
}

.topbar-btn {
  min-width: 0;
  padding: 6px 14px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: background 120ms ease, opacity 120ms ease;
}

.topbar-btn--default {
  background: #1e293b;
  color: #94a3b8;
}

.topbar-btn--force {
  background: #14532d;
  color: #dcfce7;
}

.topbar-btn--force.is-cooldown,
.hero-action--force.is-cooldown {
  background: #35556f;
  color: #e2edf7;
}

.topbar-btn--reset {
  background: #1c1917;
  color: #a8a29e;
}

.topbar-btn:hover {
  filter: brightness(1.05);
}

.topbar-btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.topbar-btn--force.is-cooldown:disabled,
.hero-action--force.is-cooldown:disabled {
  opacity: 0.82;
  cursor: default;
}

.tracked-hero {
  background: #fffbf5;
  border-left: 4px solid #d97706;
  padding: 28px 28px 26px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  border-bottom: 1px solid #e8dfd0;
}

.tracked-main {
  max-width: 640px;
}

.tracked-hero.state-in-stock {
  border-left-color: #16a34a;
  background: #fafff7;
}

.tracked-hero.state-not-found,
.tracked-hero.state-out-of-stock {
  border-left-color: #d97706;
}

.tracked-hero.state-error {
  border-left-color: #dc2626;
  background: #fff9f9;
}

.tracked-state {
  font-size: 54px;
  font-weight: 700;
  color: #92400e;
  letter-spacing: -0.06em;
  line-height: 0.96;
  margin-bottom: 12px;
  font-family: "Space Grotesk", system-ui, sans-serif;
}

.tracked-hero.state-in-stock .tracked-state {
  color: #15803d;
}

.tracked-hero.state-error .tracked-state {
  color: #dc2626;
}

.tracked-product {
  font-size: 18px;
  font-weight: 600;
  color: #1c1917;
  margin: 0 0 14px;
  line-height: 1.28;
}

.tracked-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tchip {
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  background: #f0e8dc;
  color: #92400e;
  font-weight: 600;
}

.tchip span {
  color: #a8a29e;
  font-weight: 400;
  margin-right: 3px;
}

.tracked-time {
  font-size: 12px;
  color: #a8a29e;
  margin: 0;
}

.tracked-msg {
  font-size: 13px;
  color: #78716c;
  margin: 8px 0 0;
  min-height: 0;
  max-width: 58ch;
}

.tracked-actions {
  width: 330px;
  justify-self: end;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.tracked-action-row {
  display: flex;
  gap: 10px;
}

.hero-action {
  flex: 1;
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  color: #1c1917;
}

.hero-action--force {
  background: #14532d;
  color: #dcfce7;
}

.hero-action--reset {
  background: #fff;
  border: 1.5px solid #d4c5b0;
}

.hero-action:disabled {
  opacity: 0.55;
  cursor: wait;
}

#feedbackBox {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.45;
}

#feedbackBox.success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

#feedbackBox.warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

#feedbackBox.danger {
  background: #fff1f2;
  color: #be123c;
  border: 1px solid #fecdd3;
}

#feedbackBox.neutral {
  background: #f8fafc;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.secondary-row {
  display: grid;
  grid-template-columns: 285px 1fr;
  border-bottom: 1px solid #e8dfd0;
  min-width: 0;
}

.canary-panel {
  background: #fffbf5;
  padding: 18px 20px 22px;
  border-right: 1px solid #e8dfd0;
}

.canary-head,
.history-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.sec-tag {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #a8a29e;
}

.can-name {
  font-size: 15px;
  font-weight: 600;
  color: #1c1917;
  margin: 0 0 14px;
  line-height: 1.3;
}

.can-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
}

.cs-label {
  font-size: 10px;
  color: #a8a29e;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.cs-val {
  font-size: 13px;
  font-weight: 600;
  color: #1c1917;
  margin-top: 4px;
}

.history-panel {
  background: #fffbf5;
  padding: 18px 20px 20px;
  min-width: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid #f0e8dc;
  gap: 10px;
  min-width: 0;
}

.history-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.hi-left {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.hi-title {
  font-size: 13px;
  font-weight: 600;
  color: #1c1917;
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-overflow: ellipsis;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.28;
  max-width: 100%;
}

.history-meta {
  font-size: 11px;
  color: #a8a29e;
  margin-top: 2px;
}

.history-load {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.btn-more {
  padding: 7px 18px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #e8dfd0;
  background: rgba(255,255,255,0.7);
  color: #78716c;
  cursor: pointer;
}

.btn-more:disabled {
  opacity: 0.45;
  cursor: default;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.pill.success {
  background: #dcfce7;
  color: #14532d;
}

.pill.warning {
  background: #fef3c7;
  color: #92400e;
}

.pill.danger {
  background: #fee2e2;
  color: #991b1b;
}

.pill.neutral {
  background: #f1f5f9;
  color: #64748b;
}

.history-item .pill {
  flex-shrink: 0;
}

.tab-row {
  display: flex;
  gap: 4px;
}

.tab-button {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid #d8cbb8;
  cursor: pointer;
  background: rgba(255,255,255,0.5);
  color: #8f867b;
  font-family: inherit;
}

.tab-button.active {
  background: #0f172a;
  color: #f1f5f9;
  border-color: #0f172a;
}

.footer-meta {
  background: linear-gradient(180deg, #faf8f3 0%, #f2eee7 100%);
  border-top: 1px solid #d8cbb8;
  padding: 9px 20px;
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.fm-item {
  font-size: 11px;
  color: #8c8174;
}

.fm-item strong {
  font-weight: 600;
  color: #5f5448;
  margin-right: 4px;
}

.empty-state {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: #a8a29e;
  border: 1px dashed #e8dfd0;
  border-radius: 8px;
}

@media (max-width: 1220px) {
  .page-shell {
    width: calc(100vw - 18px);
  }

  .tracked-hero {
    grid-template-columns: minmax(0, 1fr) 310px;
  }

  .tracked-actions {
    width: 310px;
  }
}

@media (max-width: 980px) {
  .page-shell {
    width: calc(100vw - 12px);
    border-radius: 14px;
  }

  .topbar {
    height: auto;
    padding: 10px 12px;
    align-items: flex-start;
    gap: 10px;
    flex-direction: column;
  }

  .topbar-right {
    width: 100%;
    flex-wrap: wrap;
  }

  .tracked-hero {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .tracked-actions {
    width: 100%;
    justify-self: stretch;
  }

  .secondary-row {
    grid-template-columns: 1fr;
  }

  .canary-panel {
    border-right: none;
    border-bottom: 1px solid #e8dfd0;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: 100%;
    margin: 0;
    border-radius: 0;
  }

  .topbar-version,
  .topbar-pill {
    display: none;
  }

  .tracked-hero {
    padding: 18px 16px;
  }

  .tracked-state {
    font-size: 40px;
  }

  .tracked-product {
    font-size: 16px;
  }

  .tracked-action-row {
    flex-direction: column;
  }

  .hero-action {
    width: 100%;
    font-size: 14px;
    padding: 13px 15px;
  }

  .can-grid {
    gap: 10px 14px;
  }

  .hi-title {
    font-size: 12px;
  }

  .history-meta,
  .fm-item {
    font-size: 10px;
  }

  .footer-meta {
    padding: 8px 14px;
    gap: 12px;
  }
}
