:root {
  color-scheme: dark;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  --page: #0d1015;
  --surface: #151a21;
  --surface-2: #1b222b;
  --surface-3: #222b35;
  --text: #f4f7fb;
  --soft: #c7d0dc;
  --muted: #7f8b9b;
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --accent: #7fd7c5;
  --accent-2: #8fb4ff;
  --warm: #e7c27b;
  --danger: #ff8c8c;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    var(--page);
  background-size: 32px 32px;
}

.auth-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 28px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: enter 0.24s ease both;
}

.auth-header,
.auth-form {
  display: grid;
  gap: 14px;
}

.auth-header h1 {
  font-size: 32px;
  line-height: 1.08;
}

.notice {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.notice.error,
.form-status.error {
  color: var(--danger);
}

.auth-form input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
}

.auth-form input:focus {
  border-color: var(--accent);
}

.form-status {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
}

.portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  background:
    radial-gradient(circle at 84% 12%, rgba(143, 180, 255, 0.08), transparent 28%),
    radial-gradient(circle at 48% 92%, rgba(127, 215, 197, 0.08), transparent 34%),
    var(--page);
}

.sidebar {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 22px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(14, 18, 24, 0.92);
}

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

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--text), #cfe3ff);
  color: #10141a;
  font-weight: 900;
}

.brand-copy strong,
.status-header strong {
  display: block;
  color: var(--text);
  font-size: 15px;
  line-height: 1.15;
}

.brand-copy small,
.status-header p,
.workspace-title p,
.tool-view-header p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.sidebar-nav {
  display: grid;
  gap: 8px;
}

.nav-button {
  min-height: 58px;
  display: grid;
  grid-template-columns: 48px 1fr;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}

.nav-button:hover,
.nav-button.active {
  background: var(--surface-2);
}

.nav-button.active {
  box-shadow: inset 3px 0 0 var(--accent), 0 10px 26px rgba(0, 0, 0, 0.16);
}

.nav-code {
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
}

.nav-copy {
  display: grid;
  gap: 3px;
}

.nav-copy strong {
  font-size: 14px;
}

.nav-copy small {
  color: var(--muted);
  font-size: 12px;
}

.status-panel {
  align-self: end;
  display: grid;
  gap: 18px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.status-header {
  display: grid;
  gap: 7px;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.usage-list {
  display: grid;
  gap: 12px;
}

.upgrade-button {
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(231, 194, 123, 0.42);
  border-radius: 10px;
  background: rgba(231, 194, 123, 0.1);
  color: var(--text);
  font-size: 13px;
  font-weight: 820;
  cursor: pointer;
}

.upgrade-button:hover {
  border-color: rgba(231, 194, 123, 0.72);
  background: rgba(231, 194, 123, 0.16);
}

.usage-meter {
  display: grid;
  gap: 8px;
}

.usage-meter-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--soft);
  font-size: 12px;
}

.usage-meter-top strong {
  color: var(--text);
}

.usage-meter-bar {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}

.usage-meter-bar span {
  display: block;
  width: var(--usage);
  min-width: 7px;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--warm));
  transition: width 0.25s ease;
}

.usage-meter.active .usage-meter-bar span {
  animation: pulse 0.9s ease-in-out infinite;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}

.workspace-top {
  min-height: 132px;
  display: flex;
  align-items: end;
  padding: 28px 34px;
  border-bottom: 1px solid var(--line);
}

.workspace-title {
  display: grid;
  gap: 8px;
}

.workspace-title h1 {
  font-size: clamp(34px, 5vw, 62px);
  line-height: 0.96;
  letter-spacing: 0;
}

.workspace-body {
  display: grid;
  grid-template-columns: minmax(420px, 760px) minmax(320px, 1fr);
  gap: 28px;
  padding: 34px;
}

.tool-stack {
  position: relative;
  min-width: 0;
}

.tool-view {
  width: 100%;
  display: none;
  gap: 22px;
  animation: enter 0.2s ease both;
}

.tool-view.active {
  display: grid;
}

.tool-view-header {
  display: grid;
  gap: 9px;
}

.tool-view-header h2 {
  font-size: 24px;
  line-height: 1.15;
}

.upload-zone {
  min-height: 250px;
  display: grid;
  place-items: center;
  gap: 10px;
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent),
    var(--surface);
  color: var(--text);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.upload-zone:hover,
.upload-zone.dragging {
  border-color: var(--accent);
  background: var(--surface-2);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-glyph {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.upload-zone strong {
  font-size: 18px;
}

.upload-zone small {
  max-width: 380px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.tool-details {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.tool-details span {
  color: var(--muted);
  font-size: 13px;
}

.tool-details strong {
  color: var(--soft);
  font-size: 13px;
  text-align: right;
  overflow-wrap: anywhere;
}

.primary-button {
  min-height: 50px;
  display: inline-grid;
  place-items: center;
  padding: 0 22px;
  border: 1px solid rgba(99, 208, 186, 0.42);
  border-radius: 9px;
  background: rgba(127, 215, 197, 0.1);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease, opacity 0.16s ease;
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(99, 208, 186, 0.82);
  background: rgba(99, 208, 186, 0.16);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.tool-action {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.tool-action::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--button-progress, 0%);
  background: linear-gradient(90deg, rgba(127, 215, 197, 0.26), rgba(143, 180, 255, 0.24));
  opacity: 0;
  transition: width 0.3s ease, opacity 0.16s ease;
  z-index: -1;
}

.tool-action.processing::before {
  opacity: 1;
}

.preview-panel {
  min-height: 620px;
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 36%),
    #0f1319;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.preview-head {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.preview-head strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
}

.preview-status {
  max-width: 180px;
  padding: 7px 10px;
  border: 1px solid rgba(127, 215, 197, 0.26);
  border-radius: 999px;
  background: rgba(127, 215, 197, 0.08);
  color: var(--soft);
  font-size: 12px;
  font-weight: 760;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.secondary-button {
  min-height: 38px;
  display: none;
  place-items: center;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--soft);
  font-size: 12px;
  font-weight: 780;
  cursor: pointer;
}

.secondary-button.visible,
.model-key-modal .secondary-button {
  display: inline-grid;
}

.secondary-button:hover {
  border-color: rgba(127, 215, 197, 0.45);
  color: var(--text);
}

.code-preview {
  margin: 0;
  padding: 18px;
  overflow: auto;
  color: #d9e4f2;
  font-family: Consolas, "Cascadia Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.62;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.code-preview::selection {
  background: rgba(127, 215, 197, 0.28);
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 17, 20, 0.78);
  animation: fade 0.18s ease both;
}

.modal-box {
  width: min(500px, 100%);
  display: grid;
  gap: 20px;
  padding: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal-copy {
  display: grid;
  gap: 10px;
}

.modal-copy h3 {
  font-size: 24px;
}

.modal-copy p,
.modal-copy small {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.modal-box .primary-button {
  justify-self: end;
}

.model-key-modal {
  width: min(680px, 100%);
}

.key-list {
  max-height: 360px;
  display: grid;
  gap: 10px;
  overflow: auto;
}

.key-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 180px;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
}

.key-row span {
  color: var(--soft);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.key-row input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  font: 13px Consolas, "Cascadia Mono", monospace;
}

.key-row input:focus {
  border-color: var(--accent);
}

.key-row input.invalid {
  border-color: var(--danger);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.payment-modal {
  width: min(560px, 100%);
}

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

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

.payment-field span {
  color: var(--soft);
  font-size: 12px;
  font-weight: 760;
}

.payment-field input {
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  outline: none;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

.payment-field input:focus {
  border-color: var(--accent);
}

.payment-result {
  min-height: 0;
}

.pix-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.pix-qr {
  width: 196px;
  height: 196px;
  justify-self: center;
  border-radius: 10px;
  background: #fff;
  object-fit: contain;
}

.pix-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pix-meta strong {
  font-size: 20px;
}

.pix-meta small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.pix-code {
  min-height: 92px;
  resize: vertical;
  padding: 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--soft);
  font: 12px Consolas, "Cascadia Mono", monospace;
  line-height: 1.45;
}

.payment-success {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 22px;
  border: 1px solid rgba(127, 215, 197, 0.38);
  border-radius: 14px;
  background: rgba(127, 215, 197, 0.08);
  text-align: center;
}

.success-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(127, 215, 197, 0.16);
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.payment-success h4 {
  font-size: 22px;
}

.payment-success p,
.payment-success small {
  max-width: 420px;
  color: var(--muted);
  line-height: 1.5;
}

.coupon-modal {
  width: min(520px, 100%);
}

.coupon-code {
  min-height: 58px;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(231, 194, 123, 0.46);
  border-radius: 12px;
  background: rgba(231, 194, 123, 0.08);
  color: var(--text);
  font: 900 24px Consolas, "Cascadia Mono", monospace;
  letter-spacing: 0.08em;
}

.backdrop,
.constellation,
.scanner,
.panel-header,
.metrics,
.tabs,
.verify-panel,
.shell,
.app-shell,
.app-frame,
.topbar,
.intro-panel,
.session-panel,
.login-shell,
.login-card {
  display: none;
}

@media (max-width: 900px) {
  .portal-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    grid-template-rows: auto auto auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .status-panel {
    align-self: stretch;
  }

  .workspace-top,
  .workspace-body {
    padding: 24px;
  }

  .workspace-body {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .auth-screen,
  .sidebar,
  .workspace-top,
  .workspace-body {
    padding: 16px;
  }

  .sidebar-nav {
    grid-template-columns: 1fr;
  }

  .tool-details {
    min-height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .upload-zone {
    min-height: 220px;
  }
}

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

@keyframes fade {
  from {
    opacity: 0;
  }
}

@keyframes pulse {
  50% {
    filter: brightness(1.35);
  }
}
