:root {
  --bg: #f3ebe3;
  --bg-deep: #1a3a3a;
  --surface: #fffdf9;
  --ink: #1c2422;
  --muted: #5c6b68;
  --accent: #c45c48;
  --accent-dark: #9e3f2e;
  --teal: #2a6b63;
  --teal-soft: #d8ebe7;
  --line: rgba(26, 58, 58, 0.12);
  --shadow: 0 10px 30px rgba(26, 58, 58, 0.08);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Segoe UI", "Avenir Next", "Century Gothic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #f7d9cf 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #cfe7e2 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
}

.page-login {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.login-wrap {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.brand-logo, .topbar-brand img {
  height: 64px;
  width: auto;
  object-fit: contain;
}

.login-wrap h1, .step h2 {
  margin: 12px 0 6px;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}

.sub, .hint {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.card-form, .choice, .list-item, .done-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-form {
  padding: 22px;
  text-align: left;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 10px 0 6px;
}

input[type="text"],
input[type="password"],
input[type="search"] {
  width: 100%;
  font-size: 1.05rem;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-block { width: 100%; margin-top: 12px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary { background: var(--teal); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--teal);
  border: 1px solid var(--line);
}
.btn-file { position: relative; overflow: hidden; }

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  text-align: left;
}
.alert-error {
  background: #fde8e4;
  color: #8a2f22;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 12px;
  background: rgba(26, 58, 58, 0.96);
  color: #f7f3ee;
  backdrop-filter: blur(8px);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.topbar-brand img { height: 42px; filter: brightness(1.05); }
.topbar-brand strong { display: block; font-size: 0.95rem; }
.topbar-brand span {
  display: block;
  font-size: 0.8rem;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}
.topbar .btn-ghost {
  color: #f7f3ee;
  border-color: rgba(255,255,255,0.25);
  min-height: 42px;
  padding: 0 14px;
}

.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 18px 16px calc(28px + var(--safe-bottom));
}

.step { display: none; }
.step.active { display: block; animation: rise 0.28s ease; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 14px;
}

.list { display: grid; gap: 10px; }
.list-item {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 12px;
  padding: 12px;
  text-align: left;
  width: 100%;
  cursor: pointer;
  color: inherit;
}
.list-item img {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
  background: #eee;
}
.list-item strong { display: block; font-size: 1.05rem; }
.list-item small { color: var(--muted); font-size: 0.85rem; }
.list-empty, .list-loading {
  padding: 24px;
  text-align: center;
  color: var(--muted);
}

.cliente-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin: 8px 0 18px;
  background: var(--teal-soft);
  border-radius: 16px;
}
.cliente-chip img {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  object-fit: cover;
}
.cliente-chip strong { display: block; }
.cliente-chip span { color: var(--muted); font-size: 0.85rem; }

.choice-grid {
  display: grid;
  gap: 12px;
}
.choice {
  padding: 18px;
  text-align: left;
  cursor: pointer;
  width: 100%;
  color: inherit;
}
.choice-title { display: block; font-size: 1.15rem; font-weight: 800; margin-bottom: 4px; }
.choice-sub { color: var(--muted); font-size: 0.92rem; }

.link-back {
  background: none;
  border: 0;
  color: var(--teal);
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0;
  margin-bottom: 8px;
  cursor: pointer;
}

.momento-wrap { margin-bottom: 18px; }
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(255,255,255,0.55);
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--line);
}
.seg-btn {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
}
.seg-btn.active {
  background: var(--teal);
  color: #fff;
}

.capture-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.preview-grid figure {
  margin: 0;
  position: relative;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  background: #ddd;
}
.preview-grid img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.preview-grid button.remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.progress {
  margin: 8px 0 12px;
  background: #e7dfd6;
  border-radius: 999px;
  overflow: hidden;
  height: 10px;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--teal), var(--accent));
  transition: width 0.2s ease;
}

.done-card {
  padding: 28px 20px;
  text-align: center;
}
.done-check {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal);
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + var(--safe-bottom));
  transform: translateX(-50%);
  background: #1a3a3a;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  max-width: 90vw;
  z-index: 50;
  box-shadow: var(--shadow);
}
.hidden { display: none !important; }

@media (min-width: 700px) {
  .capture-actions { grid-template-columns: 1fr 1fr; max-width: 480px; }
  .preview-grid { grid-template-columns: repeat(4, 1fr); }
}
