:root {
  --bg: #0f1117;
  --surface: #171a23;
  --surface-2: #1f2430;
  --border: #2a3142;
  --text: #eef1f7;
  --muted: #98a2b3;
  --accent: #ee4d2d;
  --accent-hover: #f26346;
  --green: #10b981;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --red: #ef4444;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.85em;
}

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

.small {
  font-size: 0.82rem;
}

.error-text {
  color: var(--red);
  margin: 0;
  font-size: 0.9rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  z-index: 100;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover {
  border-color: #3f4a63;
  background: #262c3b;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-2);
}

.btn-xs {
  padding: 4px 9px;
  font-size: 0.78rem;
  border-radius: 6px;
}

.full-width {
  width: 100%;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
}

input:focus,
select:focus {
  outline: 2px solid rgba(238, 77, 45, 0.4);
  border-color: var(--accent);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.85rem;
}

.field > span {
  color: var(--muted);
  font-weight: 600;
}

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

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-row h1 {
  margin: 0;
  font-size: 1.25rem;
}

.brand-row p {
  margin: 2px 0 0;
  font-size: 0.86rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
}

.brand-icon-sm {
  width: 34px;
  height: 34px;
}

.alert-box {
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

.alert-box.warn {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fde68a;
}

/* Topbar */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title {
  margin: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag-my {
  font-size: 0.72rem;
  background: rgba(238, 77, 45, 0.16);
  color: #ff8a70;
  padding: 2px 7px;
  border-radius: 99px;
  border: 1px solid rgba(238, 77, 45, 0.35);
}

.topbar-meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  gap: 6px;
  align-items: center;
}

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

/* Main Layout */
.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 18px 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-head h3 {
  margin: 0;
  font-size: 1rem;
}

.wrap-head {
  flex-wrap: wrap;
}

/* Hero */
.hero-card {
  background: linear-gradient(135deg, #1b1f2c 0%, #171a23 60%, #24191b 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 20px;
}

.hero-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.verdict-pill {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: 99px;
}

.verdict-pill.buy {
  background: rgba(16, 185, 129, 0.18);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.verdict-pill.wait {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.verdict-pill.live {
  background: rgba(59, 130, 246, 0.18);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.45);
}

.countdown-pill {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

.hero-headline {
  margin: 10px 0 6px;
  font-size: 1.45rem;
}

.hero-reason {
  margin: 0 0 12px;
  color: #d0d5dd;
  font-size: 0.94rem;
}

.advice-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.advice-item {
  font-size: 0.84rem;
  background: rgba(245, 158, 11, 0.11);
  border-left: 3px solid var(--amber);
  padding: 6px 10px;
  border-radius: 6px;
  color: #fde68a;
}

.toggle-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 99px;
  font-size: 0.8rem;
  cursor: pointer;
}

.hero-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-box {
  background: rgba(15, 17, 23, 0.65);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-box.payment-box {
  grid-column: 1 / -1;
}

.stat-box.accent-green {
  border-color: rgba(16, 185, 129, 0.35);
}

.stat-label {
  font-size: 0.76rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.35rem;
}

.stat-value-sm {
  font-size: 1.02rem;
  color: #ff8a70;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Events Strip */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.event-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.event-card.active {
  border-color: var(--green);
  background: rgba(16, 185, 129, 0.08);
}

.event-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.tier-tag {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.tier-tag.MEGA {
  color: #ff8a70;
  border-color: rgba(238, 77, 45, 0.45);
}

.tier-tag.PAYDAY {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.45);
}

.tier-tag.DOUBLE_DIGIT {
  color: #60a5fa;
}

.event-date {
  font-size: 0.82rem;
  color: var(--text);
  font-weight: 600;
}

.event-cap {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1.6fr 0.9fr;
  gap: 18px;
  align-items: start;
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Tabs & Search */
.tab-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab-btn {
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.search-input {
  max-width: 220px;
}

/* Item Cards */
.items-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
}

.item-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 12px;
}

.item-thumb {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg);
  border: 1px solid var(--border);
}

.item-thumb-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.75rem;
}

.item-body {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.item-top-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.item-title {
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-title:hover {
  color: #ff8a70;
}

.item-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.shop-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
}

.shop-badge.mall {
  background: #b91c1c;
  color: #fff;
}

.shop-badge.preferred {
  background: #ea580c;
  color: #fff;
}

.item-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.price-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.price-now {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.price-orig {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: line-through;
}

.price-flag {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 5px;
  font-weight: 600;
}

.price-flag.drop {
  background: rgba(16, 185, 129, 0.16);
  color: #34d399;
}

.price-flag.markup {
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
}

.sparkline-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
}

.item-verdict-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: rgba(15, 17, 23, 0.55);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.item-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.item-controls-left {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.target-input {
  width: 92px !important;
  padding: 4px 7px !important;
  font-size: 0.8rem !important;
}

/* Vouchers & Cards */
.voucher-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
}

.align-end {
  align-self: flex-end;
  padding-bottom: 8px;
}

.vouchers-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.voucher-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
}

.cards-matrix {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
}

.card-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
}

.card-role {
  font-size: 0.72rem;
  color: #ff8a70;
  font-weight: 600;
}

.card-rule {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--muted);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 90;
}

.modal-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-head h3 {
  margin: 0;
}

@media (max-width: 920px) {
  .hero-card,
  .main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .item-card {
    grid-template-columns: 1fr;
  }
  .item-thumb,
  .item-thumb-placeholder {
    width: 56px;
    height: 56px;
  }
}
