:root {
  color-scheme: dark;
  --bg: #101113;
  --panel: #181a1d;
  --panel-2: #202328;
  --ink: #f7f3ec;
  --muted: #a7a197;
  --line: #34373d;
  --amber: #e6a23a;
  --amber-2: #ffc45c;
  --paper: #fffaf0;
  --paper-ink: #151515;
  --danger: #e76f51;
  --radius: 8px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(230, 162, 58, 0.12), transparent 26%),
    radial-gradient(circle at 90% 5%, rgba(255, 196, 92, 0.12), transparent 28%),
    var(--bg);
  color: var(--ink);
}

button,
input,
a {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.topbar,
.workspace,
.history-section {
  animation: rise 420ms ease both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.store-label {
  margin: 0 0 4px;
  color: var(--amber-2);
  font-size: 0.83rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.3rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.88rem;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #57d68d;
  box-shadow: 0 0 0 4px rgba(87, 214, 141, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.customer-workspace {
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
}

.tool-panel,
.preview-panel,
.history-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(24, 26, 29, 0.94);
  box-shadow: var(--shadow);
}

.tool-panel,
.preview-panel {
  padding: 18px;
}

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

.panel-heading span,
.helper-text {
  color: var(--muted);
  font-size: 0.84rem;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #111315;
  color: var(--ink);
  outline: none;
  transition: border 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(230, 162, 58, 0.16);
}

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

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.customer-summary {
  grid-template-columns: repeat(2, 1fr);
}

.summary-strip div {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px;
  background: var(--panel-2);
}

.summary-strip span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.summary-strip strong {
  font-size: 1rem;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.ghost-button,
.link-box button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 160ms ease, border 160ms ease, background 160ms ease, color 160ms ease;
}

.primary-button {
  background: var(--amber);
  color: #17130c;
  font-weight: 800;
}

.secondary-button {
  background: var(--paper);
  color: var(--paper-ink);
  font-weight: 800;
}

.ghost-button,
.link-box button,
.text-button {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.link-box button:hover,
.text-button:hover {
  transform: translateY(-1px);
}

.disabled {
  pointer-events: none;
  opacity: 0.42;
}

.download-panel {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.download-panel h2 {
  margin-bottom: 10px;
}

.link-box {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 8px;
  margin-bottom: 10px;
}

.link-box input {
  overflow: hidden;
  text-overflow: ellipsis;
}

.helper-text {
  margin: 10px 0 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.preview-panel {
  min-height: 100%;
}

.coupon-stage {
  display: grid;
  place-items: center;
  min-height: 610px;
  border: 1px solid #2b2e33;
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    #121416;
  background-size: 34px 34px;
  padding: 28px;
  overflow: hidden;
}

.coupon-card {
  position: relative;
  width: min(100%, 620px);
  aspect-ratio: 1.08;
  padding: clamp(22px, 4vw, 36px);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(230, 162, 58, 0.2), transparent 28%),
    linear-gradient(180deg, var(--paper), #f3e7cf);
  color: var(--paper-ink);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.42);
  overflow: hidden;
}

.coupon-card::before,
.coupon-card::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #121416;
  transform: translateY(-50%);
}

.coupon-card::before {
  left: -18px;
}

.coupon-card::after {
  right: -18px;
}

.coupon-topline,
.coupon-meta {
  position: relative;
  z-index: 1;
}

.coupon-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  color: #5f5649;
  font-size: clamp(0.68rem, 1.3vw, 0.82rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.coupon-logo {
  width: min(38%, 210px);
  height: auto;
  object-fit: contain;
}

.coupon-copy {
  position: relative;
  z-index: 1;
  margin: clamp(8px, 1.7vw, 14px) 0 14px;
  color: #5d5345;
  font-size: clamp(1.35rem, 3vw, 2.55rem);
  font-weight: 750;
}

.discount-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.discount-grid div {
  border: 1px solid rgba(21, 21, 21, 0.16);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.45);
}

.discount-grid span,
.discount-grid small {
  display: block;
  color: #5d5345;
  font-size: clamp(0.68rem, 1.2vw, 0.8rem);
  font-weight: 800;
  text-transform: uppercase;
}

.discount-grid strong {
  display: block;
  font-size: clamp(2.25rem, 5vw, 4.1rem);
  line-height: 0.95;
}

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

.coupon-meta-compact {
  grid-template-columns: repeat(3, 1fr);
}

.coupon-bottom {
  position: relative;
  z-index: 1;
}

.coupon-meta p {
  margin: 0;
  min-width: 0;
}

.coupon-meta span,
.coupon-meta strong {
  display: block;
}

.coupon-meta span {
  color: #756b5e;
  font-size: clamp(0.62rem, 1vw, 0.75rem);
  font-weight: 800;
  text-transform: uppercase;
}

.coupon-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: clamp(0.72rem, 1.22vw, 0.9rem);
}

.coupon-terms {
  position: relative;
  z-index: 1;
  margin: 14px 0 0;
  color: #756b5e;
  font-size: clamp(0.58rem, 1vw, 0.72rem);
  font-weight: 650;
}

.history-section {
  margin-top: 18px;
  padding: 18px;
}

.text-button {
  min-height: 32px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.history-table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 13px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
  font-size: 0.9rem;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  text-align: right;
}

.load-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .coupon-stage {
    min-height: auto;
    padding: 16px;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .field-grid,
  .summary-strip,
  .discount-grid,
  .coupon-meta {
    grid-template-columns: 1fr;
  }

  .coupon-card {
    aspect-ratio: auto;
    min-height: 700px;
  }

  .coupon-logo {
    width: min(52%, 190px);
  }

  .button-row {
    flex-direction: column;
  }

  .primary-button,
  .secondary-button,
  .ghost-button {
    width: 100%;
  }
}
