:root {
  --bg: #0b0c0e;
  --surface: #14161a;
  --surface-elevated: #1b1e24;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f4f4f6;
  --text-secondary: #a1a6b0;
  --text-muted: #6c727f;
  --accent: #ff5a1f;
  --accent-hover: #ff703d;
  --accent-soft: rgba(255, 90, 31, 0.14);
  --ok: #22c55e;
  --warn-bg: rgba(245, 158, 11, 0.1);
  --warn-border: rgba(245, 158, 11, 0.35);
  --warn-text: #fcd34d;
  --danger: #ef4444;
  --radius-lg: 18px;
  --radius-md: 12px;
  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(640px 340px at 14% -4%, rgba(255, 90, 31, 0.12), transparent 70%),
    radial-gradient(520px 300px at 88% 8%, rgba(59, 130, 246, 0.06), transparent 70%);
  z-index: 0;
}

.mono {
  font-family: var(--font-mono);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1080px;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(40px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(145deg, #ff6b35, #e04108);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(255, 90, 31, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  flex-shrink: 0;
}

.brand-copy {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.brand-tag {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-badge.is-ok .status-dot {
  background: var(--ok);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.7);
}

.status-badge.is-warn .status-dot {
  background: #f59e0b;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(255, 90, 31, 0.25);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-elevated);
  border-color: var(--border-strong);
}

.btn-icon-only {
  width: 40px;
  padding: 0;
}

.btn-danger-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
  width: 40px;
  padding: 0;
}

.btn-danger-ghost:hover:not(:disabled) {
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  align-items: end;
  padding: 32px 0 26px;
}

.hero-eyebrow {
  margin: 0 0 10px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-weight: 500;
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.2vw, 2.5rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 700;
}

.hero-desc {
  margin: 12px 0 0;
  color: var(--text-secondary);
  font-size: 0.96rem;
  line-height: 1.55;
  max-width: 56ch;
}

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

.meta-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.meta-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.meta-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* Alerts */
.alerts {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  font-size: 0.88rem;
  line-height: 1.45;
}

/* Toolbar */
.toolbar {
  margin-bottom: 18px;
}

.search-wrap {
  position: relative;
  display: block;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.search-wrap input:focus {
  border-color: var(--accent);
}

/* Grid & Cards */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.app-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.app-card:hover {
  border-color: var(--border-strong);
}

.app-head {
  display: flex;
  gap: 14px;
  align-items: center;
}

.app-icon {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-strong);
  display: grid;
  place-items: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}

.app-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.app-icon-fallback {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--accent);
}

.app-meta {
  min-width: 0;
  flex: 1;
}

.app-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-bundle {
  margin: 4px 0 0;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-specs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.spec-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.spec-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.spec-val {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.app-actions .btn-install {
  flex: 1;
  min-height: 44px;
}

.app-actions .btn-icon-only,
.app-actions .btn-danger-ghost {
  height: 44px;
  width: 44px;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 56px 20px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
}

/* Footer */
.footer {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Modales */
.modal {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 480px;
  width: calc(100% - 24px);
  margin: auto;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.modal-card {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 600;
}

.modal-sub {
  margin: 3px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 26px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.drop-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--surface-elevated);
  color: var(--accent);
  display: grid;
  place-items: center;
  margin-bottom: 10px;
}

.drop-zone p {
  margin: 0 0 4px;
  font-size: 0.92rem;
}

.drop-zone-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.field-full {
  grid-column: 1 / -1;
}

.field input {
  height: 40px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
}

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

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.progress-bar {
  flex: 1;
  height: 7px;
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.1s linear;
}

.progress-label {
  font-size: 0.8rem;
  min-width: 40px;
  text-align: right;
  color: var(--text-secondary);
}

.form-error {
  color: var(--danger);
  font-size: 0.84rem;
  margin: 10px 0 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.qr-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.qr-box {
  padding: 14px;
  background: #ffffff;
  border-radius: 14px;
  min-height: 204px;
  min-width: 204px;
  display: grid;
  place-items: center;
}

.copy-row {
  display: flex;
  width: 100%;
  gap: 8px;
}

.copy-row input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.extra-links {
  display: flex;
  gap: 18px;
  font-size: 0.82rem;
}

.extra-links a {
  color: var(--accent);
  text-decoration: none;
}

.extra-links a:hover {
  text-decoration: underline;
}

.guide-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.guide-list strong {
  color: var(--text);
}

.guide-list code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg);
  color: var(--accent);
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 24px 0 20px;
  }
}

@media (max-width: 540px) {
  .fields-grid {
    grid-template-columns: 1fr;
  }
  .topbar-actions {
    width: 100%;
  }
  .topbar-actions .btn {
    flex: 1;
  }
  .status-badge {
    width: 100%;
    justify-content: center;
  }
  .apps-grid {
    grid-template-columns: 1fr;
  }
}
