:root {
  /* Updated Color Palette */
  --bg: #0d111c;
  --card: #16213e;
  --muted: #8c9aaf;
  --text: #e0e6f7;
  --accent: #60a5fa;
  --accent-light: #93c5fd;
  --accent-dark: #2563eb;
  --success: #34d399;
  --warning: #facc15;
  --danger: #ef4444;
  --ring: rgba(96, 165, 250, 0.4);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, "Noto Sans", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
  color: var(--text);
  background: radial-gradient(1000px 700px at 85% -150px, #1a2747 10%, transparent 70%), var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

/* Layout */
.wrap {
  max-width: 1100px;
  margin-inline: auto;
  padding: 32px 20px 80px;
}

header {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

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

.logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-light), var(--accent-dark));
  box-shadow: var(--shadow);
  transition: transform 0.3s ease;
}

.logo:hover {
  transform: scale(1.05);
}

h1 {
  font-size: clamp(28px, 3vw + 16px, 42px);
  margin: 0;
  letter-spacing: .5px;
  font-weight: 800;
}

.subtitle {
  color: var(--muted);
  margin-top: 2px;
  font-size: 1.05em;
}

/* Controls */
.controls {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
  margin-top: 16px;
}

@media (min-width: 760px) {
  .controls {
    grid-template-columns: 1.5fr 1fr 1fr;
  }
}

.control {
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.control svg {
  color: var(--muted);
  flex-shrink: 0;
}

.control input,
.control select {
  appearance: none;
  background: transparent;
  border: none;
  outline: none;
  width: 100%;
  color: var(--text);
  font-size: 15px;
}

.control input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.control:focus-within {
  box-shadow: 0 0 0 4px var(--ring);
  border-color: var(--accent);
}

/* Grid Layout */
.grid {
  display: grid;
  gap: 18px;
  margin-top: 30px;
  grid-template-columns: 1fr;
}

@media (min-width: 560px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 980px) {
  .grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.45);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px 10px;
  background: rgba(255, 255, 255, 0.03);
}

.store-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex: 0 0 auto;
  background: #0f1933;
  border: 1px solid rgba(255, 255, 255, .2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1em;
  color: var(--accent-light);
}

.store-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.store-name {
  font-weight: 700;
  font-size: 1.1em;
}

.pill {
  margin-left: auto;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 600;
  white-space: nowrap;
}

.pill:not(.expired) {
  background: rgba(52, 211, 153, .15);
  color: var(--success);
  border: 1px solid rgba(52, 211, 153, .4);
}

.pill.expired {
  background: rgba(239, 68, 68, .15);
  color: var(--danger);
  border-color: rgba(239, 68, 68, .4);
}

.pill[aria-label="Expiring soon"] {
  background: rgba(250, 204, 21, .15) !important;
  color: var(--warning) !important;
  border-color: rgba(250, 204, 21, .4) !important;
}

.card-body {
  padding: 12px 18px 18px;
  display: grid;
  gap: 12px;
}

.desc {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.4;
}

/* Code Row */
.code-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.code {
  flex: 1;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-align: center;
  background: #0a1120;
  border: 1px dashed rgba(255, 255, 255, .25);
  padding: 12px 14px;
  border-radius: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Buttons */
.btn {
  cursor: pointer;
  user-select: none;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 12px;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, .04));
  transition: transform .1s ease, filter .2s ease, box-shadow .2s ease, background 0.2s ease;
  white-space: nowrap;
}

.btn:hover {
  filter: brightness(1.1);
  background: linear-gradient(180deg, rgba(255, 255, 255, .1), rgba(255, 255, 255, .06));
}

.btn:active {
  transform: translateY(2px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  filter: grayscale(1);
  transform: none;
  box-shadow: none;
}

/* Call to Action */
.cta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.cta a {
  text-decoration: none;
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 12px 16px;
  background: linear-gradient(180deg, var(--accent-light), var(--accent));
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  letter-spacing: .5px;
  transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
  box-shadow: 0 4px 10px rgba(96, 165, 250, 0.3);
  flex-shrink: 0;
}

.cta a::after {
  content: '→';
  font-size: 1.2em;
  line-height: 1;
  margin-left: 4px;
}

.cta a:hover {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(96, 165, 250, 0.4);
}

.cta a:active {
  transform: translateY(0);
}

/* Meta */
.meta {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  flex-wrap: wrap;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .35);
}

.small {
  font-size: 13px;
  color: var(--muted);
}

/* Footer */
footer {
  margin-top: 40px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Utilities */
.hide {
  display: none !important;
}

.empty {
  border: 1px dashed rgba(255, 255, 255, .25);
  border-radius: 14px;
  padding: 30px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, .04);
  font-size: 1.1em;
  margin-top: 30px;
}

/* Loader Styles */
#loader {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #0d111c;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 6px solid rgba(255, 255, 255, 0.2);
  border-top: 6px solid #60a5fa;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
