/* Hallmark stamp — Obra Clara premium redesign */
/* Critique: denser attention hierarchy, persistent nav, phase progress, zero dead taps */

:root {
  --bg: #F4F4F0;
  --surface: #FFFFFF;
  --text: #111111;
  --text-2: #5C5C56;
  --text-3: #8A8A84;
  --border: #E4E4DE;
  --lima: #B8F000;
  --lima-dim: #A3D600;
  --danger: #DC2626;
  --success: #16A34A;
  --pending: #CA8A04;
  --warn-bg: #FEF9C3;
  --warn-text: #854D0E;
  --nav: #111111;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 64px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { overflow-x: clip; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--lima); outline-offset: 2px; }

#app {
  min-height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

/* ——— Shell ——— */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + var(--safe-b));
}
.app-shell.no-nav { padding-bottom: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-title p { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--text); color: var(--lima);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); flex-shrink: 0;
}
.icon-btn:active { background: var(--bg); }

main.page { flex: 1; padding: 12px 16px 24px; }

/* ——— Bottom nav ——— */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 0 8px var(--safe-b);
  background: var(--nav);
  display: flex; align-items: stretch; justify-content: space-around;
  z-index: 40;
  border-radius: 20px 20px 0 0;
}
.nav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: rgba(255,255,255,.45);
  font-size: 10px; font-weight: 500;
  min-height: 44px;
  position: relative;
  transition: color .15s ease;
}
.nav-item.active { color: var(--lima); }
.nav-item svg { width: 22px; height: 22px; }
.nav-badge {
  position: absolute;
  top: 6px; right: calc(50% - 18px);
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--lima); color: var(--text);
  border-radius: 8px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ——— Cards & lists ——— */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.card-press { transition: transform .12s ease; }
.card-press:active { transform: scale(0.985); }

.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  margin: 16px 0 8px;
  letter-spacing: 0.01em;
}

/* ——— Stats row ——— */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
}
.stat.highlight {
  background: var(--lima);
  border-color: var(--lima);
}
.stat-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.stat-label { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.stat.highlight .stat-label { color: var(--text); opacity: .7; }

/* ——— Filters ——— */
.filters {
  display: flex; gap: 6px; overflow-x: auto;
  margin-bottom: 12px; padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
}
.filter {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 13px; font-weight: 550;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.filter.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

/* ——— Obra row ——— */
.obra-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.obra-card:active { background: #FAFAF8; }
.obra-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
}
.obra-name { font-size: 15px; font-weight: 650; letter-spacing: -0.01em; }
.obra-meta { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.pct-pill {
  flex-shrink: 0;
  background: var(--lima);
  color: var(--text);
  font-size: 12px; font-weight: 700;
  padding: 4px 8px; border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.progress-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px 0 8px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: width .4s ease;
}
.obra-foot {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-3);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: 6px;
}
.chip-lima { background: var(--lima); color: var(--text); }
.chip-danger { background: #FEE2E2; color: var(--danger); }
.chip-warn { background: var(--warn-bg); color: var(--warn-text); }
.chip-muted { background: var(--bg); color: var(--text-3); }

/* ——— Attention block ——— */
.attention {
  background: var(--warn-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.attention-title {
  font-size: 13px; font-weight: 650; color: var(--warn-text);
  margin-bottom: 6px;
}
.attention ul { list-style: none; }
.attention li {
  font-size: 13px; color: var(--warn-text);
  padding: 3px 0; padding-left: 14px; position: relative;
}
.attention li::before {
  content: "";
  position: absolute; left: 0; top: 9px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--pending);
}

/* ——— Buttons ——— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 0 18px;
  border-radius: 12px;
  font-size: 15px; font-weight: 600;
  transition: transform .12s ease, opacity .15s;
}
.btn:active { transform: scale(0.97); }
.btn-lima { background: var(--lima); color: var(--text); }
.btn-dark { background: var(--text); color: var(--surface); }
.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
}
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; font-size: 13px; padding: 0 14px; border-radius: 10px; }
.btn-row { display: flex; gap: 8px; margin-top: 12px; }
.btn-row .btn { flex: 1; }

/* ——— Login ——— */
.login-wrap {
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding: 24px 20px;
  background: var(--bg);
}
.login-brand {
  text-align: center; margin-bottom: 28px;
}
.login-logo {
  width: 52px; height: 52px; border-radius: 14px;
  background: var(--text); color: var(--lima);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; margin-bottom: 12px;
}
.login-brand h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.login-brand p { font-size: 14px; color: var(--text-2); margin-top: 4px; }
.login-card {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 22px 20px;
}
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 13px; font-weight: 550;
  color: var(--text-2); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  height: 48px; padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: 16px;
}
.field textarea { height: auto; min-height: 72px; padding: 10px 14px; }
.field input[type="file"] { height: auto; padding: 10px 14px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--text);
  outline: none;
}
.login-error {
  background: #FEE2E2; color: var(--danger);
  font-size: 13px; padding: 10px 12px; border-radius: 10px;
  margin-bottom: 12px;
}
.demo-hint {
  margin-top: 16px; text-align: center;
  font-size: 12px; color: var(--text-3);
  display: flex; justify-content: center; flex-wrap: wrap; column-gap: 12px;
}
.demo-hint button {
  color: var(--text); font-weight: 600; text-decoration: underline;
}

/* ——— Phase progress (client) ——— */
.phase-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.phase-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px;
}
.phase-now { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.phase-pct {
  font-size: 28px; font-weight: 750; letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
.phase-dots {
  display: flex; gap: 6px; margin: 12px 0 8px;
}
.phase-dot {
  flex: 1; height: 6px; border-radius: 3px;
  background: var(--border);
}
.phase-dot.done { background: var(--text); }
.phase-dot.current { background: var(--lima); }
.phase-sub {
  display: flex; justify-content: space-between;
  font-size: 12px; color: var(--text-3);
}

/* ——— List rows ——— */
.row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row-title { font-size: 14px; font-weight: 600; }
.row-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.row-amount {
  font-size: 14px; font-weight: 650;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.status {
  font-size: 11px; font-weight: 650; margin-top: 2px; text-align: right;
}
.status-ok { color: var(--success); }
.status-wait { color: var(--pending); }
.status-bad { color: var(--danger); }

/* ——— Client hero ——— */
.client-hero {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  background: #2A2A28;
  aspect-ratio: 16/10;
  position: relative;
  display: flex; align-items: flex-end;
}
.client-hero-label {
  position: absolute; left: 12px; bottom: 12px; right: 12px;
  display: flex; justify-content: space-between; align-items: center;
}
.client-hero-label span {
  background: rgba(0,0,0,.75); color: #fff;
  font-size: 12px; font-weight: 550;
  padding: 6px 10px; border-radius: 8px;
  max-width: 70%;
}
.client-hero-label .photo-count {
  background: var(--lima); color: var(--text);
  font-weight: 700;
}

/* ——— Empty / loading ——— */
.empty {
  text-align: center; padding: 48px 24px;
  color: var(--text-3);
}
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }
.spinner {
  width: 28px; height: 28px; margin: 0 auto 12px;
  border: 3px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page > .chips { margin: 6px 0 14px; }
.client-title { font-size: 22px; line-height: 1.2; }
.approved-extras { font-size: 14px; }
.approved-extras strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.share-link { margin-top: 12px; }
.btn-sm, .demo-hint button { min-height: 44px; }
.btn:disabled { opacity: .55; cursor: wait; }
.login-message { margin-bottom: 12px; color: var(--success); }
.row-end { text-align: right; flex-shrink: 0; }
.phase-row, .list-button { width: 100%; text-align: left; }
.phase-row { display: flex; align-items: center; gap: 10px; }
.phase-row .row-title, .phase-row .row-sub { display: block; }
.phase-index {
  width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%;
  display: grid; place-items: center; background: var(--bg); font-weight: 700;
}
.phase-index.hecha { background: var(--lima); }
.phase-index.en_curso { color: var(--lima); background: var(--text); }
.hero-img, .photo-card img { display: block; width: 100%; object-fit: cover; }
.hero-img { position: absolute; inset: 0; height: 100%; }
.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.photo-card { overflow: hidden; padding: 0; }
.photo-card img { aspect-ratio: 1; }
.photo-card figcaption { padding: 8px 10px; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4);
  display: flex; justify-content: center; align-items: flex-end;
}
.modal {
  width: min(100%, 480px); background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 12px 16px calc(20px + var(--safe-b)); max-height: 85dvh; overflow: auto;
}
.modal-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto 14px; }
.modal-title { font-size: 17px; margin-bottom: 8px; }
.modal > .row-sub { margin-bottom: 14px; }
.budget-fields {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
}
.budget-part {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .85fr) minmax(0, 1.25fr) minmax(0, 1.55fr) 32px;
  gap: 6px; align-items: end;
  border: 1px solid var(--border); border-radius: 12px; padding: 8px; margin-bottom: 8px;
}
.budget-fields .field, .budget-part .field { margin: 0; min-width: 0; }
.budget-fields input, .budget-fields select, .budget-part input { min-width: 0; height: 42px; padding: 0 8px; }
.budget-part .field:first-child { grid-column: 1 / 5; }
.budget-part .field label { margin-bottom: 3px; font-size: 12px; }
.budget-remove { grid-column: 5; font-size: 20px; padding: 0; min-height: 42px; }
.budget-line-total { grid-column: 4 / 6; text-align: right; }
.budget-line-total output { display: grid; align-items: center; min-height: 42px; font-weight: 700; overflow-wrap: anywhere; }
.budget-notes { margin-top: 12px; }
.list-button { display: block; }
.budget-summary { min-width: 0; }
.budget-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.budget-table th, .budget-table td {
  padding: 8px 3px; border-bottom: 1px solid var(--border); text-align: right; overflow-wrap: anywhere;
}
.budget-table th:first-child { width: 35%; padding-left: 0; text-align: left; }
.budget-table th:nth-child(2) { width: 17%; }
.budget-table th:last-child, .budget-table td:last-child { padding-right: 0; }
.budget-table thead { color: var(--text-2); font-size: 12px; }
.budget-totals { display: grid; gap: 6px; margin-top: 12px; font-size: 14px; }
.budget-totals div { display: flex; justify-content: space-between; gap: 8px; }
.budget-totals div:last-child { font-size: 17px; font-weight: 700; }
.budget-totals dd { margin: 0; }
.budget-detail-notes p { white-space: pre-wrap; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ——— Demo pública ——— */
.demo-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 12px 8px 16px;
  background: var(--nav); color: #fff;
  font-size: 12px;
}
.demo-bar-note { color: rgba(255,255,255,.7); line-height: 1.3; }
.demo-switch {
  display: flex; flex-shrink: 0; padding: 3px; gap: 2px;
  background: rgba(255,255,255,.1); border-radius: 999px;
}
.demo-switch a {
  min-height: 32px; padding: 0 12px; border-radius: 999px;
  display: flex; align-items: center;
  font-weight: 600; color: rgba(255,255,255,.75);
}
.demo-switch a[aria-current="page"] { background: var(--lima); color: var(--text); }
.login-note { text-align: center; margin: 16px 0 8px; }

/* ——— Mi empresa ——— */
.avatar-img { background: var(--surface); border: 1px solid var(--border); overflow: hidden; }
.avatar-img img { width: 100%; height: 100%; object-fit: contain; }
.business-preview { display: grid; gap: 10px; }
.business-preview-head { display: flex; align-items: center; gap: 12px; }
.business-welcome { color: var(--text-2); font-size: 14px; }
#empresa-form { display: grid; gap: 4px; }
.check-row { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: 14px; color: var(--text-2); }
.contact-card { display: grid; gap: 4px; }

/* ——— Propuestas del cliente ——— */
.chip-proposal { background: var(--warn-bg); color: var(--warn-text); }
.proposal { display: grid; gap: 8px; }
.proposal-answer { font-size: 14px; color: var(--text-2); }
.proposal-form { display: grid; gap: 10px; margin-top: 16px; }
.proposal-form textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 16px; background: var(--surface); resize: vertical; }

/* ——— Fotos rápidas y diario ——— */
.quick-photo { gap: 8px; cursor: pointer; }
.quick-photo svg { width: 20px; height: 20px; }
.quick-hint { text-align: center; margin: 6px 0 4px; }
.diary-form { display: grid; gap: 10px; }
.diary-form textarea { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 16px; background: var(--surface); resize: vertical; }
.diary-list { display: grid; gap: 0; }
.diary-entry { padding: 10px 0; border-bottom: 1px solid var(--border); display: grid; gap: 4px; }
.diary-entry:last-child { border-bottom: 0; }
.diary-entry p { font-size: 15px; }
.diary-del { justify-self: start; }

/* ——— Ficha de fase (cliente) ——— */
.phase-link { display: flex; align-items: center; gap: 8px; }
.phase-link .row { flex: 1; }
.phase-chevron { color: var(--text-3); font-size: 22px; line-height: 1; }
.back-link { justify-content: flex-start; gap: 6px; margin-bottom: 10px; }
.phase-detail { display: grid; gap: 8px; }
.phase-desc { font-size: 15px; color: var(--text-2); white-space: pre-line; }
.notice-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quick-phase { display: flex; align-items: center; gap: 8px; justify-content: center; margin: 8px 0 4px; font-size: 13px; color: var(--text-2); }
.quick-phase select { font-size: 16px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); max-width: 60vw; }

/* ——— Plantillas y fases editables ——— */
.empty-phases { display: grid; gap: 10px; }
.template-choice { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.template-choice input { margin-top: 4px; width: 20px; height: 20px; accent-color: var(--text); flex-shrink: 0; }
.template-choice > span { display: grid; gap: 2px; }
.template-card { display: grid; gap: 8px; }
.templates-hint { margin: -4px 0 10px; }
.phase-tools { margin-top: 8px; }
.btn.danger { color: var(--danger); }
.delete-job { margin-top: 28px; }

/* ——— Prueba y exportación ——— */
.trial-bar { padding: 10px 16px; font-size: 13px; line-height: 1.4; background: var(--warn-bg); color: var(--warn-text); }
.trial-bar a { font-weight: 650; text-decoration: underline; }
.trial-bar.trial-soon { background: #FFEDD5; color: #9A3412; }
.trial-bar.trial-over { background: #FEE2E2; color: #991B1B; }
.trial-bar.trial-wait { background: var(--bg); color: var(--text-2); }
.export-form { display: grid; gap: 10px; }
.export-list { margin: 8px 0 8px 18px; display: grid; gap: 6px; font-size: 14px; color: var(--text-2); }
/* Modo consulta: se ocultan los botones que cambian datos (la base de datos tampoco lo permitiría). */
.read-only .btn-lima:not(.keep), .read-only [data-modal], .read-only .quick-photo, .read-only .quick-phase,
.read-only #diario-form, .read-only #empresa-form button, .read-only [data-phase-state], .read-only [data-pay],
.read-only [data-proposal], .read-only #delete-job, .read-only [data-diary-del], .read-only [data-del-plantilla],
.read-only #edit-budget, .read-only #mark-budget-accepted { display: none !important; }
.trial-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.trial-close { min-width: 36px; min-height: 36px; font-size: 20px; line-height: 1; color: inherit; opacity: .7; border-radius: 8px; flex-shrink: 0; }
