:root {
  --bg: #07111d;
  --bg-soft: #0d1a2b;
  --panel: #101d2d;
  --panel-2: #13263b;
  --line: rgba(148, 183, 222, 0.18);
  --line-bright: rgba(143, 205, 255, 0.42);
  --text: #f1f7ff;
  --muted: #9fb1c7;
  --soft: #718399;
  --blue: #73b9ff;
  --cyan: #77ded6;
  --gold: #f1c96b;
  --danger: #ff8585;
  --ok: #8ee6a7;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(115, 185, 255, 0.14), transparent 34%),
    linear-gradient(180deg, #07111d, #05080d 72%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: linear-gradient(180deg, #000, transparent 90%);
  pointer-events: none;
}

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

button,
input,
select {
  font: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 76px;
  padding: 12px 6vw;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 17, 29, 0.86);
  backdrop-filter: blur(18px);
}

.brand,
.app-header nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-bright);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(115, 185, 255, 0.2), rgba(119, 222, 214, 0.18));
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--soft);
  font-size: 12px;
}

.app-header nav {
  flex-wrap: wrap;
  gap: 22px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 750;
}

.app-header nav a:hover,
.app-header nav a:focus-visible {
  color: var(--text);
}

main {
  padding: 44px 6vw 72px;
}

.hero-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: 22px;
  align-items: stretch;
  margin-bottom: 22px;
}

.hero-section > div,
.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.022));
  box-shadow: var(--shadow);
}

.hero-section > div:first-child {
  padding: 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
  overflow-wrap: anywhere;
}

h1 {
  max-width: 780px;
  margin-bottom: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 48px;
  line-height: 1.02;
  overflow-wrap: anywhere;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.hero-section p:not(.eyebrow) {
  max-width: 800px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.72;
}

.rule-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 18px;
}

.rule-grid div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.rule-grid strong,
.rule-grid span {
  display: block;
}

.rule-grid strong {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 24px;
}

.rule-grid span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

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

.panel {
  min-width: 0;
  padding: 20px;
}

.panel-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.count-pill,
.grade-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  max-width: 100%;
  white-space: nowrap;
}

.grade-pill.grade-b,
.status-pill.is-warning {
  color: var(--gold);
}

.grade-pill.grade-c,
.grade-pill.grade-d,
.status-pill.is-danger {
  color: var(--danger);
}

.grade-pill.grade-a {
  color: var(--ok);
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  background: rgba(4, 11, 20, 0.82);
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--line-bright);
  box-shadow: 0 0 0 3px rgba(115, 185, 255, 0.11);
}

.result-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  margin-top: 14px;
  overflow: auto;
  padding-right: 4px;
}

.result-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.result-item:hover,
.result-item:focus-visible,
.result-item.is-selected {
  border-color: var(--line-bright);
  background: rgba(115, 185, 255, 0.08);
}

.result-item strong,
.result-item span,
.result-item small {
  display: block;
  overflow-wrap: anywhere;
}

.result-item span,
.result-item small,
.selected-card span {
  color: var(--muted);
  font-size: 12px;
}

.selected-card {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.selected-card strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.condition-grid,
.inline-fields {
  display: grid;
  gap: 12px;
}

.condition-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
}

.summary-panel {
  grid-column: 1;
}

.terms-panel {
  grid-column: 2;
  grid-row: span 2;
}

.price-stack,
.term-grid {
  display: grid;
  gap: 10px;
}

.price-stack {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.price-stack div,
.term-grid div {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.price-stack span,
.term-grid span,
.final-price span,
.redeem-box span,
.extension-box span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.price-stack strong,
.term-grid strong,
.final-price strong,
.redeem-box strong,
.extension-result strong {
  display: block;
  color: var(--text);
  overflow-wrap: anywhere;
}

.final-price,
.redeem-box {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(115, 185, 255, 0.13), rgba(119, 222, 214, 0.1));
}

.final-price strong,
.redeem-box strong {
  font-size: 30px;
}

.final-price small,
.extension-result small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 850;
}

.primary-button {
  margin-top: 14px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: #07111d;
}

.secondary-button {
  border-color: var(--line-bright);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.ghost-button {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.ghost-button:focus-visible {
  transform: translateY(-1px);
}

.term-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 14px;
}

.extension-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.65fr);
  gap: 14px;
  align-items: stretch;
  margin-top: 14px;
}

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

.segmented button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.16);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.segmented button.is-active,
.segmented button:hover,
.segmented button:focus-visible {
  border-color: var(--line-bright);
  color: var(--text);
  background: rgba(115, 185, 255, 0.12);
}

.extension-result {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.action-row .primary-button,
.action-row .secondary-button {
  margin-top: 0;
}

.history-panel {
  margin-top: 18px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.16);
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

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

  .summary-panel,
  .terms-panel {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

  .app-header nav {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }

  main {
    padding: 24px 18px 48px;
  }

  .hero-section,
  .workspace-grid {
    display: block;
  }

  .hero-section > div + div,
  .workspace-grid > .panel + .panel,
  .history-panel {
    margin-top: 18px;
  }

  h1 {
    width: 100%;
    max-width: 100%;
    font-size: 32px;
  }

  .hero-section > div:first-child,
  .panel {
    width: calc(100vw - 36px);
    max-width: calc(100vw - 36px);
    padding: 18px;
  }

  .hero-section p:not(.eyebrow),
  h1 {
    max-width: calc(100vw - 72px);
  }

  .count-pill,
  .grade-pill,
  .status-pill {
    justify-content: flex-start;
    white-space: normal;
  }

  .condition-grid,
  .inline-fields,
  .price-stack,
  .term-grid,
  .extension-box {
    grid-template-columns: 1fr;
  }

  .final-price strong,
  .redeem-box strong {
    font-size: 26px;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .result-item {
    grid-template-columns: 1fr;
  }

  .result-item small {
    text-align: left;
  }
}
