:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface-2: #1c1c26;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --accent: #b026ff;
  --accent-2: #22d3ee;
  --accent-hover: #9a1de8;
  --accent-soft: rgba(176, 38, 255, 0.12);
  --bg-2: #0a0a13;
  --text: #e8e8f0;
  --text-muted: #6b6b80;
  --text-dim: #4a4a5e;
  --danger: #ff5577;
  --success: #4ade80;
  --warning: #fbbf24;
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  background-image:
    linear-gradient(rgba(255,255,255,0.014) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.014) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: 0 0;
}

.mono, label, .label, .badge, code, kbd {
  font-family: 'Space Mono', ui-monospace, 'Cascadia Code', monospace;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover { color: var(--accent-hover); }

.center-screen {
  min-height: 100vh; min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.card-narrow { width: 100%; max-width: 400px; }
.card-medium { width: 100%; max-width: 520px; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.brand-mark {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Mono', monospace;
  font-weight: 700;
  color: #fff;
  font-size: 18px;
}
.brand-name {
  font-family: 'Space Mono', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand-logo {
  height: 40px;
  width: auto;
  display: block;
}
.sidebar-brand .brand-logo,
.sidebar .brand-logo {
  height: 28px;
}

h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.subtitle { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }

.field { margin-bottom: 16px; }
label, .label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 16px; /* 16px mínimo — evita zoom automático no iOS Safari */
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  background: #1f1f2b;
}

input::placeholder { color: var(--text-dim); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field-error {
  color: var(--danger);
  font-size: 12px;
  margin-top: 6px;
  font-family: 'Space Mono', monospace;
  display: none;
}
.field-error.show { display: block; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  background: linear-gradient(155deg, #cc33ff 0%, #7722cc 52%, #5522bb 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
  width: 100%;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 14px rgba(180, 40, 255, 0.22),
              inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 45%;
  background: linear-gradient(to bottom, rgba(255,255,255,0.09), transparent);
  pointer-events: none;
}
.btn:hover {
  background: linear-gradient(155deg, #d944ff 0%, #8833dd 52%, #6633cc 100%);
  box-shadow: 0 4px 22px rgba(180, 40, 255, 0.38),
              inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #25252f; }
.btn-row { display: flex; gap: 8px; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
  display: none;
}
.alert.show { display: block; }
.alert-error {
  background: rgba(255, 85, 119, 0.08);
  border-color: rgba(255, 85, 119, 0.25);
  color: #ff8aa3;
}
.alert-warning {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.25);
  color: var(--warning);
}
.alert-info {
  background: var(--accent-soft);
  border-color: rgba(176, 38, 255, 0.3);
  color: #c98bff;
}
.alert-success {
  background: rgba(74, 222, 128, 0.08);
  border-color: rgba(74, 222, 128, 0.25);
  color: #4ade80;
}

.muted { color: var(--text-muted); font-size: 13px; }
.text-center { text-align: center; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

.link-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-muted);
}
.badge-accent {
  background: var(--accent-soft);
  border-color: rgba(176, 38, 255, 0.3);
  color: #c98bff;
}
.badge-success {
  background: rgba(74, 222, 128, 0.1);
  border-color: rgba(74, 222, 128, 0.3);
  color: var(--success);
}

.plans-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  width: 100%;
  max-width: 800px;
}
.plan-card { position: relative; padding: 28px 24px; }
.plan-card.popular { border-color: var(--accent); }
.plan-card .badge-popular {
  position: absolute;
  top: -10px;
  right: 20px;
}
.plan-name {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.plan-price {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 4px;
}
.plan-price small { font-size: 14px; color: var(--text-muted); font-weight: 400; }
.plan-saving { font-size: 12px; color: var(--success); font-family: 'Space Mono', monospace; margin-bottom: 16px; }
.plan-benefits {
  list-style: none;
  margin: 20px 0 24px;
  padding: 0;
}
.plan-benefits li {
  padding: 7px 0;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.plan-benefits li:last-child { border-bottom: none; }
.plan-benefits li::before {
  content: '+';
  color: var(--accent);
  font-family: 'Space Mono', monospace;
  font-weight: 700;
}
.pay-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.pay-buttons .btn {
  padding: 9px 8px;
  font-size: 12px;
}

.app-shell {
  min-height: 100vh; min-height: 100svh;
  display: flex;
  flex-direction: column;
}
.app-header {
  display: flex;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 16px;
}
.app-header .brand { margin: 0; flex: 0; }
.header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  margin-left: auto;
}
.header-user {
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
}
.header-actions { display: flex; gap: 8px; align-items: center; }

.app-main {
  flex: 1;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 0;
  min-height: 0;
}

.panel {
  background: var(--surface);
  padding: 24px;
  overflow: auto;
}
.panel.right {
  background: var(--bg);
  border-left: 1px solid var(--border);
  padding: 0;
  position: relative;
}

.section-label {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 18px 0 10px;
}
.section-label:first-child { margin-top: 0; }

.drop-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--surface-2);
}
.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.drop-zone-icon {
  font-family: 'Space Mono', monospace;
  font-size: 24px;
  color: var(--accent);
  margin-bottom: 8px;
}
.drop-zone-title { font-size: 14px; }
.drop-zone-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.slot-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.slot {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.slot.filled { border-color: var(--accent); }
.slot img { width: 100%; height: 100%; object-fit: cover; }
.slot-num {
  position: absolute;
  top: 4px; left: 4px;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(0,0,0,0.6);
  padding: 2px 5px;
  border-radius: 3px;
}
.slot-remove {
  position: absolute;
  top: 4px; right: 4px;
  width: 32px; height: 32px;
  border-radius: 6px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  display: none;
}
.slot.filled .slot-remove { display: flex; align-items: center; justify-content: center; }

.tips-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-muted);
}
.tips-box .label { margin-bottom: 8px; color: var(--accent); }
.tips-box ul { padding-left: 18px; }
.tips-box li { margin-bottom: 4px; }

#viewer-canvas-wrap { position: absolute; inset: 0; }
.viewer-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  pointer-events: none;
}
.viewer-icon {
  font-family: 'Space Mono', monospace;
  font-size: 56px;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.viewer-state .label-line {
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
}
.viewer-state h2 { color: var(--text-muted); font-weight: 400; }

/* Photo guide box — visible in state-idle */
#state-idle {
  justify-content: flex-start;
  padding-top: 28px;
  overflow: hidden;
}
.photo-guide-box {
  pointer-events: auto;
  width: calc(100% - 16px);
  max-width: 420px;
  max-height: 58vh;
  overflow-y: auto;
  margin-top: 14px;
  background: rgba(108, 99, 255, 0.07);
  border: 1px solid rgba(108, 99, 255, 0.35);
  border-radius: 10px;
  padding: 14px 16px 16px;
  text-align: left;
  scrollbar-width: thin;
  scrollbar-color: rgba(108,99,255,0.4) transparent;
}
.photo-guide-box::-webkit-scrollbar { width: 4px; }
.photo-guide-box::-webkit-scrollbar-thumb { background: rgba(108,99,255,0.4); border-radius: 4px; }
.photo-guide-box::-webkit-scrollbar-track { background: transparent; }
.guide-box-title {
  font-family: 'Space Mono', monospace;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.8px;
  color: var(--accent);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.guide-box-title::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 13px;
  background: var(--accent);
  border-radius: 2px;
  flex-shrink: 0;
}
.guide-section { margin-bottom: 12px; }
.guide-section:last-child { margin-bottom: 0; }
.guide-section-label {
  font-family: 'Space Mono', monospace;
  font-size: 8.5px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(160, 150, 255, 0.9);
  margin-bottom: 5px;
}
.guide-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.guide-section li {
  font-size: 12px;
  color: rgba(220, 218, 235, 0.88);
  padding: 2.5px 0 2.5px 14px;
  position: relative;
  line-height: 1.55;
}
.guide-section li::before {
  content: '›';
  position: absolute;
  left: 0;
  color: rgba(140, 130, 255, 0.9);
  font-size: 13px;
  line-height: 1.3;
}
.guide-tag-required {
  font-size: 9px;
  color: rgba(160, 150, 255, 1);
  font-family: 'Space Mono', monospace;
  letter-spacing: 0.5px;
}

.progress-ring-wrap {
  width: 140px; height: 140px;
  position: relative;
  margin-bottom: 20px;
}
.progress-ring-wrap svg { transform: rotate(-90deg); }
.progress-ring-bg { stroke: var(--border-strong); }
.progress-ring-fg { stroke: var(--accent); transition: stroke-dashoffset 0.3s; }
.progress-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 22px;
  color: var(--text);
}

.viewer-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 6px;
  z-index: 10;
}
.viewer-controls .btn {
  width: auto;
  padding: 7px 12px;
  font-size: 12px;
}

/* ─── Credits badge ─────────────────────────────────────────────────────── */
.credits-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--accent-soft);
  border: 1px solid rgba(176,38,255,0.3);
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: #c98bff;
}
.credits-badge.low {
  background: rgba(255,85,119,0.08);
  border-color: rgba(255,85,119,0.25);
  color: #ff8aa3;
}

/* ─── Client list table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }

.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.status-dot::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
}
.status-dot.active::before { background: var(--success); }
.status-dot.pending::before { background: var(--warning); }

/* ─── Client detail tabs ────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tab {
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ─── Model gallery ─────────────────────────────────────────────────────── */
.model-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.model-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s;
}
.model-card:hover { border-color: var(--accent); }
.model-card-thumb {
  height: 140px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Mono', monospace;
  font-size: 32px;
  color: var(--text-dim);
  position: relative;
  overflow: hidden;
}
.model-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.thumb-badge {
  position: absolute;
  bottom: 6px;
  left: 8px;
  background: rgba(0,0,0,0.65);
  color: var(--accent);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  line-height: 1.4;
}
.model-card-body { padding: 12px; }
.model-card-date { font-size: 12px; color: var(--text-muted); font-family: 'Space Mono', monospace; }

/* ─── Assessment timeline ───────────────────────────────────────────────── */
.assessment-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}
.stat-label {
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}
.stat-unit {
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── Diet card ─────────────────────────────────────────────────────────── */
.diet-content {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ─── Invite link box ───────────────────────────────────────────────────── */
.invite-box {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-family: 'Space Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}
.invite-box .btn {
  width: auto;
  padding: 6px 14px;
  font-size: 12px;
  flex-shrink: 0;
}

/* ─── Slot grid named views ─────────────────────────────────────────────── */
.slot-grid-named {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.slot-empty-icon {
  font-size: 24px;
  color: var(--text-dim);
}

/* ─── Client portal header ──────────────────────────────────────────────── */
.portal-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.portal-greeting {
  font-size: 14px;
  color: var(--text-muted);
}
.portal-greeting strong { color: var(--text); }

/* ─── Empty state ───────────────────────────────────────────────────────── */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state-icon {
  font-size: 40px;
  color: var(--text-dim);
  margin-bottom: 12px;
  font-family: 'Space Mono', monospace;
}

@media (max-width: 900px) {
  .app-main { grid-template-columns: 1fr; }
  .panel.right { min-height: 400px; border-left: 0; border-top: 1px solid var(--border); }
  .plans-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .slot-grid-named { grid-template-columns: repeat(2, 1fr); }
  .model-gallery { grid-template-columns: repeat(2, 1fr); }
  .assessment-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .app-header { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .app-header .brand img { height: 22px; }
  .header-meta { flex-direction: row; align-items: center; gap: 8px; }
  .panel { padding: 16px; }
}
@supports (padding: env(safe-area-inset-bottom)) {
  .center-screen { padding-bottom: env(safe-area-inset-bottom); }
  .app-header { padding-top: max(10px, env(safe-area-inset-top)); }
}
