*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
  min-height: 100vh;
  padding: 30px 16px;
  color: #e2e8f0;
}

.container {
  max-width: 780px;
  margin: 0 auto;
}

h1 {
  text-align: center;
  font-size: 1.8rem;
  font-weight: 700;
  background: linear-gradient(90deg, #a78bfa, #60a5fa, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 6px;
}

.subtitle {
  text-align: center;
  font-size: 0.85rem;
  color: #94a3b8;
  margin-bottom: 28px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-card-link {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: normal;
}

.card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: #a78bfa;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(167, 139, 250, 0.2);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.form-grid.triple {
  grid-template-columns: 1fr 1fr 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  font-size: 0.78rem;
  font-weight: 500;
  color: #94a3b8;
}

.input-wrap {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-wrap:focus-within {
  border-color: #a78bfa;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.input-wrap .prefix {
  padding: 0 10px;
  font-size: 0.8rem;
  color: #64748b;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  height: 100%;
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.15);
  white-space: nowrap;
}

input[type="text"],
input[type="number"],
input[type="date"] {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: #e2e8f0;
  font-family: 'Inter', sans-serif;
}

input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.7);
  cursor: pointer;
}

.calc-field input {
  color: #34d399;
  font-weight: 600;
}

.ref-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.bonus-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.bonus-row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.bonus-row:last-child {
  margin-bottom: 0;
}

.btn-group {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

button {
  flex: 1;
  padding: 13px 20px;
  border: none;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: 'Inter', sans-serif;
}

.btn-generate {
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: white;
}

.btn-generate:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(124, 58, 237, 0.4);
}

.btn-copy {
  background: linear-gradient(135deg, #34d399, #059669);
  color: white;
}

.btn-copy:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(5, 150, 105, 0.4);
}

.btn-reset {
  background: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  border: 1px solid rgba(255, 255, 255, 0.1);
  flex: 0 0 auto;
  padding: 13px 18px;
}

.btn-reset:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

.output-box {
  display: none;
  margin-top: 20px;
}

.output-box.visible {
  display: block;
}

.output-content {
  background: #0d1117;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  line-height: 1.8;
  color: #e2e8f0;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #34d399;
  color: #064e3b;
  padding: 12px 20px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
  z-index: 999;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.ref-field-wrapper {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}

.btn-remove {
  background: rgba(255, 59, 48, 0.8);
  color: white;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-remove:hover {
  background: rgba(255, 59, 48, 1);
  transform: translateY(-1px);
}

.btn-add-row {
  background: linear-gradient(135deg, rgba(110, 231, 183, 0.6), rgba(52, 211, 153, 0.6));
  color: #ffffff;
  border: 1px solid rgba(110, 231, 183, 0.4);
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.6rem;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-block;
  white-space: nowrap;
  margin-top: 5px;
}

.btn-add-row:hover {
  background: linear-gradient(135deg, rgba(110, 231, 183, 0.9), rgba(52, 211, 153, 0.9));
  border-color: rgba(110, 231, 183, 0.8);
  box-shadow: 0 2px 8px rgba(110, 231, 183, 0.2);
  transform: translateY(-1px);
}

.ref-name-label {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.15s;
  display: inline-block;
}

.ref-name-label:hover {
  background: rgba(167, 139, 250, 0.1);
  color: #c4b5fd;
}

.ref-name-input-inline {
  width: 100%;
  max-width: 150px;
  padding: 4px 6px;
  border: 1px solid #a78bfa;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 0.78rem;
  font-family: inherit;
}

.ref-name-input-inline:focus {
  outline: none;
  border-color: #c4b5fd;
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.2);
}

.ref-header {
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.ref-header .card-title {
  margin-bottom: 0;
}

.field-no-margin {
  margin-bottom: 0;
}

.ref-name-input {
  width: 100%;
  padding: 6px;
  border: none;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  font-size: 0.75rem;
  font-family: 'Inter', sans-serif;
}

.bonus-total-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.hidden-template {
  display: none;
}

@media (max-width: 560px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid.triple {
    grid-template-columns: 1fr 1fr;
  }

  .ref-grid {
    grid-template-columns: 1fr;
  }

  .bonus-row {
    grid-template-columns: 1fr;
  }
}