/* BRITO PANEL — mismo carácter que el portafolio: tinta, crema y oro */
:root {
  --bg: #0F0F0E; --card: #171615; --card2: #1E1D1B; --fg: #ECE7DD; --muted: #A39E95; --acc: #C49A5A;
  --line: rgba(236, 231, 221, .1); --line2: rgba(236, 231, 221, .18);
  --ok: #6FBF8B; --warn: #E0B04F; --bad: #E2735F;
  --r: 16px; --g: clamp(16px, 4vw, 28px);
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--fg); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; text-align: left; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--acc); font-weight: 600; }
.brand { white-space: nowrap; display: flex; align-items: center; gap: .55rem; font-weight: 700; letter-spacing: .02em; }
.mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--acc); color: #141210; font-size: .75rem; font-weight: 800; letter-spacing: -.02em; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: 0 1.1rem;
  border-radius: 999px; border: 1px solid var(--line2); font-weight: 600; font-size: .92rem; text-decoration: none; white-space: nowrap;
  transition: background .2s, border-color .2s, color .2s;
}
.btn:hover { border-color: var(--fg); }
.btn.solid { background: var(--fg); color: #141210; border-color: var(--fg); }
.btn.solid:hover { background: #fff; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.small { min-height: 36px; padding: 0 .9rem; font-size: .84rem; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; pointer-events: none; }
.link { color: var(--acc); font-size: .85rem; font-weight: 600; }
.acts { display: flex; flex-wrap: wrap; gap: .5rem; margin: .9rem 0; }

/* Acceso */
.gate { min-height: 100vh; display: grid; place-items: center; padding: var(--g); }
.gate-card { width: min(420px, 100%); display: grid; gap: 1.1rem; }
.gate-card h1 { font-size: 1.9rem; font-weight: 500; letter-spacing: -.02em; margin-top: .6rem; }
.gate-card .muted { margin-top: .3rem; }
.qr { background: #fff; border-radius: 14px; padding: 12px; width: 200px; margin: .8rem 0; }
.qr img { width: 100%; display: block; }
.secret { font-size: .8rem; color: var(--muted); word-break: break-all; }
.secret code { color: var(--fg); }
.err { color: var(--bad); font-size: .9rem; min-height: 1.2em; }

/* Formularios */
.form { display: grid; gap: .85rem; margin-top: 1rem; }
.form label { display: grid; gap: .35rem; font-size: .82rem; color: var(--muted); font-weight: 500; }
.form label small { font-size: .74rem; color: var(--muted); opacity: .85; }
.form input:not([type="checkbox"]), .form select, .form textarea {
  width: 100%; min-height: 46px; padding: .6rem .8rem; border-radius: 12px; border: 1px solid var(--line2);
  background: var(--card2); color: var(--fg); font-size: 16px; outline: none; transition: border-color .2s;
}
.form textarea { min-height: 90px; resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--acc); }
.form .check { display: flex; align-items: center; gap: .6rem; font-size: .95rem; color: var(--fg); min-height: 44px; }
.form .check input { width: 22px; height: 22px; accent-color: var(--acc); }
.form .btn.solid { margin-top: .4rem; }

/* Estructura */
.app { min-height: 100vh; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: .7rem;
  padding: calc(.7rem + env(safe-area-inset-top)) var(--g) .7rem; background: rgba(15, 15, 14, .88);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line);
}
.top .brand { margin-right: auto; }
.demo-tag { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--warn); border: 1px solid currentColor; border-radius: 999px; padding: .2rem .6rem; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(6, 1fr);
  padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom)); background: rgba(20, 19, 18, .96);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
}
.nav button { display: grid; justify-items: center; gap: .1rem; padding: .45rem 0; border-radius: 12px; color: var(--muted); font-size: .64rem; font-weight: 600; }
.nav i { font-style: normal; font-size: 1.15rem; line-height: 1; }
.nav button.is-on { color: var(--acc); background: rgba(196, 154, 90, .1); }
.main { padding: 1rem var(--g) calc(6rem + env(safe-area-inset-bottom)); max-width: 1100px; margin: 0 auto; display: grid; gap: 1rem; align-content: start; }
.view-title { font-size: clamp(1.7rem, 6vw, 2.4rem); font-weight: 500; letter-spacing: -.03em; margin: .4rem 0 .2rem; }

/* Tarjetas */
.card, .hero { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem; }
.card h2, .group h2 { font-size: 1rem; font-weight: 650; margin-bottom: .7rem; }
.card h2 small, .group h2 small { color: var(--muted); font-weight: 500; margin-left: .25rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.start { border-color: var(--acc); background: linear-gradient(135deg, rgba(196, 154, 90, .14), transparent 60%), var(--card); }
.start p { margin-bottom: .2rem; }
.hero { background: radial-gradient(120% 120% at 100% 0%, rgba(196, 154, 90, .2), transparent 55%), var(--card); display: grid; gap: .9rem; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.kpi b { display: block; font-size: clamp(1.7rem, 7vw, 2.6rem); font-weight: 600; letter-spacing: -.03em; line-height: 1; }
.kpi b small { font-size: .5em; color: var(--muted); font-weight: 500; }
.kpi span { font-size: .8rem; color: var(--muted); }
.goal-head { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; }
.goal-head b { color: var(--fg); }
.bar { height: 10px; border-radius: 99px; background: rgba(236, 231, 221, .08); overflow: hidden; }
.bar i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #8E6A35, var(--acc)); transition: width .8s cubic-bezier(.16, 1, .3, 1); }
.mini-kpis { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8rem; color: var(--muted); padding-top: .3rem; border-top: 1px solid var(--line); }
.mini-kpis b { color: var(--fg); }

/* Listas */
.list { display: grid; gap: .45rem; }
.row, .task {
  display: flex; align-items: center; gap: .8rem; width: 100%; min-height: 58px; padding: .65rem .85rem;
  border-radius: 13px; background: var(--card2); border: 1px solid var(--line); transition: border-color .2s;
}
.row:hover, .task:hover { border-color: var(--line2); }
.row-main { display: grid; gap: .1rem; flex: 1; min-width: 0; }
.row-main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-main small { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: grid; justify-items: end; gap: .2rem; flex: 0 0 auto; font-size: .85rem; }
.row-side small { color: var(--muted); font-size: .72rem; }
.badge { display: inline-block; font-size: .7rem; font-weight: 700; padding: .2rem .55rem; border-radius: 999px; background: rgba(236, 231, 221, .08); color: var(--muted); text-transform: capitalize; white-space: nowrap; }
.badge.ok, .badge.s-activo { color: var(--ok); background: rgba(111, 191, 139, .12); }
.badge.warn, .badge.s-propuesta { color: var(--warn); background: rgba(224, 176, 79, .12); }
.badge.bad { color: var(--bad); background: rgba(226, 115, 95, .14); }
.badge.s-contacto { color: #8FB4E8; background: rgba(143, 180, 232, .12); }
.task { padding: .5rem .85rem .5rem .55rem; }
.tick { flex: 0 0 auto; width: 32px; height: 32px; border-radius: 10px; border: 1.5px solid var(--line2); display: grid; place-items: center; color: #141210; font-weight: 800; }
.task.is-done .tick { background: var(--ok); border-color: var(--ok); }
.task.is-done .row-main b { text-decoration: line-through; color: var(--muted); }
.task .row-main { text-align: left; }
.alert { display: flex; gap: .7rem; align-items: flex-start; width: 100%; padding: .7rem .85rem; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); font-size: .88rem; }
.alert i { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; margin-top: .42rem; background: var(--warn); }
.alert.bad i { background: var(--bad); box-shadow: 0 0 0 4px rgba(226, 115, 95, .18); }
.alert b { font-weight: 650; }
.empty { display: grid; justify-items: start; gap: .8rem; padding: 1.4rem; border: 1px dashed var(--line2); border-radius: var(--r); color: var(--muted); }
.note { font-size: .84rem; color: var(--muted); background: rgba(196, 154, 90, .08); border: 1px solid rgba(196, 154, 90, .25); border-radius: 12px; padding: .6rem .8rem; }
.notes { white-space: pre-wrap; color: var(--muted); font-size: .92rem; margin: .4rem 0 .8rem; }
details.group summary { cursor: pointer; color: var(--muted); font-weight: 600; padding: .4rem 0 .7rem; }
.tools { display: grid; gap: .6rem; }
.tools input { width: 100%; min-height: 46px; padding: .6rem .9rem; border-radius: 999px; border: 1px solid var(--line2); background: var(--card); font-size: 16px; outline: none; }
.tools input:focus { border-color: var(--acc); }
.chips { display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; margin: 0 calc(var(--g) * -1); padding: 0 var(--g); }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; min-height: 34px; padding: 0 .85rem; border-radius: 999px; border: 1px solid var(--line2); font-size: .8rem; color: var(--muted); text-transform: capitalize; }
.chip.is-on { background: var(--fg); color: #141210; border-color: var(--fg); }

/* Ficha (hoja) */
.sheet {
  margin: auto 0 0; width: 100%; max-width: none; max-height: 92vh; border: 0; border-radius: 22px 22px 0 0;
  background: var(--card); color: var(--fg); padding: 0; box-shadow: 0 -20px 60px rgba(0, 0, 0, .5);
}
.sheet::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.sheet[open] { animation: up .35s cubic-bezier(.16, 1, .3, 1); }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-in { padding: 1rem var(--g) calc(1.6rem + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; overscroll-behavior: contain; display: grid; gap: .5rem; }
.sheet-in h1 { font-size: 1.6rem; font-weight: 550; letter-spacing: -.02em; }
.sheet-top { display: flex; justify-content: space-between; gap: .5rem; margin: 0 -.5rem .3rem; }
.sheet .group { margin-top: 1rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(5.4rem + env(safe-area-inset-bottom)); z-index: 50; transform: translate(-50%, 20px);
  background: var(--fg); color: #141210; font-weight: 600; font-size: .88rem; padding: .6rem 1.1rem; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Ordenador: menú lateral, más columnas */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 230px 1fr; grid-template-rows: auto 1fr; }
  .top { grid-column: 1 / -1; }
  .nav {
    position: sticky; top: 64px; bottom: auto; align-self: start; height: calc(100vh - 64px); display: flex; flex-direction: column; gap: .25rem;
    padding: 1.2rem .8rem; background: transparent; border-top: 0; border-right: 1px solid var(--line);
  }
  .nav button { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; font-size: .92rem; justify-items: start; }
  .nav i { width: 22px; text-align: center; }
  .main { padding: 1.6rem 2.2rem 3rem; width: 100%; }
  .main > .hero { grid-template-columns: 1.1fr 1fr; align-items: center; }
  .main > .hero .eyebrow, .main > .hero .kpis { grid-column: 1; }
  .main > .hero .goal { grid-column: 2; }
  .main > .hero .mini-kpis { grid-column: 1 / -1; }
  .main > .hero .kpis { grid-row: 2 / span 2; }
  .sheet { margin: auto; width: min(640px, 92vw); border-radius: 22px; max-height: 88vh; }
  .sheet-in { max-height: 88vh; padding: 1.4rem 1.8rem 1.8rem; }
  .form { grid-template-columns: 1fr 1fr; }
  .form label:has(textarea), .form .btn.solid, .form label:has(select[name="client_id"]) { grid-column: 1 / -1; }
  .toast { bottom: 2rem; }
  .list.cols, .main > .list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Entrar con Face ID / huella */
.passkey-box { display: grid; gap: .6rem; margin: 1rem 0 .4rem; }
.passkey-box .btn { width: 100%; padding-block: .9rem; font-size: 1rem; }
.passkey-box .or { text-align: center; font-size: .85rem; opacity: .6; margin: 0; }
