:root {
  --bg: #f2f6f7;
  --card: #ffffff;
  --ink: #112233;
  --ink-soft: #495f6d;
  --accent: #008060;
  --accent-2: #2f9f87;
  --warn: #bc3f37;
  --edge: #d5dee3;
  --glow: rgba(0, 128, 96, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Lexend", sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

body.modal-open {
  overflow: hidden;
}

.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 10% 10%, rgba(47, 159, 135, 0.22), transparent 35%),
    radial-gradient(circle at 90% 90%, rgba(0, 128, 96, 0.24), transparent 30%),
    linear-gradient(140deg, #f8fbfc, #e8f0f2 55%, #deebee);
}

.topbar {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 18px 8px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
}

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

.brand h1 {
  font-family: "Space Grotesk", sans-serif;
  margin: 0;
  font-size: clamp(1.3rem, 2.6vw, 2rem);
}

.brand p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-weight: 700;
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: white;
  box-shadow: 0 12px 30px var(--glow);
}

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 18px 40px;
}

.auth-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--edge);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(17, 34, 51, 0.05);
}

#app-section > .card {
  margin-bottom: 14px;
}

.flip-card-container {
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
  display: grid;
}

.flip-card-container.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
  grid-area: 1 / 1;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.flip-card-back {
  transform: rotateY(180deg);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

h2 {
  margin-top: 0;
  margin-bottom: 10px;
}

h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.card-header-flex h2 {
  margin-bottom: 0;
}

.purchase-history-list {
  max-height: 250px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.purchase-history-list::-webkit-scrollbar {
  width: 6px;
}

.purchase-history-list::-webkit-scrollbar-thumb {
  background: var(--edge);
  border-radius: 4px;
}

.tabs {
  display: inline-flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  border: 1px solid var(--edge);
  background: #f6f8f9;
  color: var(--ink-soft);
  border-radius: 12px;
  padding: 8px 14px;
  font-weight: 600;
  cursor: pointer;
}

.tab.active {
  background: #deefe8;
  border-color: #b2d8ca;
  color: #0f4738;
}

.form {
  display: grid;
  gap: 12px;
  max-width: 520px;
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.tab-panels {
  width: 100%;
}

.convert-tab-panel {
  display: grid;
  gap: 8px;
  width: 100%;
}

.convert-tab-panel input {
  width: 100%;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  border: 1px solid #c5d3db;
  border-radius: 12px;
  padding: 10px 12px;
  background: #fcfdff;
}

input[type="file"] {
  padding: 8px;
  color: var(--ink-soft);
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 6px 14px;
  border: 1px solid #c9d6dd;
  border-radius: 8px;
  background: #eef5f7;
  color: var(--ink);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
}

input[type="file"]::file-selector-button:hover {
  background: #e0ecf2;
  border-color: #b5c7cf;
  color: var(--accent);
}

button {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.primary {
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff;
}

.ghost {
  background: #eef5f7;
  color: var(--ink);
  border: 1px solid #c9d6dd;
}

.danger {
  background: #fbe5e4;
  color: #8f2a24;
  border: 1px solid #f1b9b6;
}

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

.muted {
  margin-top: 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.summary {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.summary .row {
  display: flex;
  justify-content: space-between;
  border: 1px solid #e1e8ec;
  border-radius: 12px;
  padding: 8px 10px;
  background: #fafcfd;
}

.credits-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.credit-pack-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pack {
  background: #ecf8f3;
  border: 1px solid #bfe7d8;
  color: #0d5a47;
  min-width: 170px;
}

.custom-credit-pack {
  background: #f8fbfd;
  border: 1px solid #d7e2e8;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
  text-align: center;
  transition: all 0.3s ease;
}

.custom-credit-pack h3 {
  margin: 0;
  font-size: 1rem;
}

.custom-credit-pack input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: #d7e2e8;
  border-radius: 4px;
  outline: none;
  cursor: pointer;
  transition: background 0.3s ease;
  margin: 10px 0;
}

.custom-credit-pack input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--glow);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s ease;
}

.custom-credit-pack input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.custom-credit-pack input[type="range"]::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--glow);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s ease;
}

.custom-credit-pack input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.15);
}

.custom-credit-pack p {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.custom-credit-pack button {
  width: 100%;
}

.mega-badge {
  display: none;
  background: linear-gradient(145deg, #f39c12, #e67e22);
  color: #fff;
  font-size: 0.7rem;
  padding: 3px 6px;
  border-radius: 8px;
  margin-left: 6px;
  vertical-align: middle;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.custom-credit-pack.mega-pack {
  border-color: #f5b041;
  background: #fffdf8;
  box-shadow: 0 4px 16px rgba(243, 156, 18, 0.15);
}

.custom-credit-pack.mega-pack p {
  color: #d68910;
}

.custom-credit-pack.mega-pack input[type="range"] {
  background: #fdebd0;
}

.custom-credit-pack.mega-pack input[type="range"]::-webkit-slider-thumb {
  background: #e67e22;
  box-shadow: 0 2px 8px rgba(230, 126, 34, 0.4);
}

.custom-credit-pack.mega-pack input[type="range"]::-moz-range-thumb {
  background: #e67e22;
  box-shadow: 0 2px 8px rgba(230, 126, 34, 0.4);
}

.custom-credit-pack.mega-pack .mega-badge {
  display: inline-block;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { transform: scale(0); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.status {
  min-height: 20px;
  margin-top: 10px;
  font-weight: 500;
}

.status.loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.status.loading::before {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid #b8d7cd;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: 0 0 auto;
}

.status.error {
  color: #a32f28;
}

.status.success {
  color: #0f6d51;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.download-area {
  margin-top: 10px;
}

.download-link {
  display: inline-block;
  background: #e2f5ee;
  border: 1px solid #b3dfcd;
  border-radius: 12px;
  padding: 10px 12px;
  color: #074537;
  text-decoration: none;
  font-weight: 600;
}

.trial-card {
  align-self: start;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.history-header h2 {
  margin: 0;
  flex-shrink: 0;
}

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

.history-label {
  font-size: 0.92rem;
  color: var(--ink-soft);
  font-weight: 500;
}

.history-filter-buttons {
  display: flex;
  gap: 6px;
}

.history-filter-btn {
  background: #eef5f7;
  color: var(--ink);
  border: 1px solid #c9d6dd;
  border-radius: 8px;
  padding: 6px 12px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-filter-btn:hover {
  background: #e0ecf2;
  border-color: #b5c7cf;
}

.history-filter-btn.active {
  background: linear-gradient(145deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: var(--accent);
}

.history-clear-btn {
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.history-clear-btn:hover {
  background: #fbe5e4;
  border-color: #f1b9b6;
  color: #8f2a24;
}

.history-loading {
  text-align: center;
  padding: 12px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 500;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #e2eaef;
  border-radius: 12px;
  padding: 10px;
  background: #fbfdff;
}

.history-item .meta {
  display: block;
  color: var(--ink-soft);
  font-size: 0.82rem;
  margin-top: 3px;
}

.badge {
  font-size: 0.8rem;
  background: #e5f3ee;
  color: #0b5a47;
  border-radius: 999px;
  padding: 5px 10px;
}

.badge.error {
  background: #fbe5e4;
  color: #8f2a24;
}

.badge.canceled {
  background: #f2f6f7;
  color: #495f6d;
}

.grid-pro {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.block-label {
  display: block;
  margin-bottom: 8px;
}

.viewer-wrapper {
  margin-top: 10px;
  border: 1px solid #d6e1e8;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

#pdf-viewer {
  width: 100%;
  min-height: 420px;
  border: none;
}

.ai-result {
  border: 1px solid #d8e2e8;
  border-radius: 12px;
  background: #fbfdff;
  padding: 10px;
  min-height: 90px;
  white-space: pre-wrap;
}

.pix-modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 21, 32, 0.55);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 30;
}

.pix-modal-card {
  width: min(860px, 100%);
  background: #fff;
  border: 1px solid #d5dee3;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 22px 54px rgba(17, 34, 51, 0.22);
}

.pix-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 14px;
  align-items: start;
}

.pix-qr-box {
  border: 1px solid #d7e2e8;
  border-radius: 14px;
  background: #f8fbfd;
  padding: 12px;
  display: grid;
  gap: 8px;
  justify-items: center;
}

#pix-qr-image {
  width: 216px;
  height: 216px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #d7e2e8;
}

.pix-info {
  display: grid;
  gap: 8px;
}

#pix-code {
  width: 100%;
  min-height: 92px;
  font-family: "Space Grotesk", monospace;
  font-size: 0.85rem;
}

.hidden {
  display: none !important;
}

code {
  background: #edf3f6;
  padding: 2px 6px;
  border-radius: 6px;
}

@media (max-width: 680px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .layout {
    padding-top: 0;
  }

  .form-inline {
    flex-direction: column;
    align-items: stretch;
  }

  .auth-grid {
    grid-template-columns: 1fr;
  }

  .pix-layout {
    grid-template-columns: 1fr;
  }

  .pix-qr-box {
    justify-items: start;
  }

  .credits-container {
    grid-template-columns: 1fr;
  }
}
