:root {
  --navy-950: #082237;
  --navy-800: #123e5a;
  --blue-600: #1676a4;
  --blue-100: #dff2fa;
  --paper: #f5f8fa;
  --white: #fff;
  --ink: #17232b;
  --muted: #65747d;
  --line: #d5dfe4;
  --danger: #a52a2a;
  --radius: 10px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
button, input, select, textarea { font: inherit; }
.muted { color: var(--muted); }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(23rem, 100%); background: var(--white); padding: 2rem; border-radius: 14px; box-shadow: 0 14px 45px rgb(8 34 55 / .12); }
.login-card h1 { margin: 0; color: var(--navy-950); }
.login-card p { margin: .35rem 0 1.25rem; }
.login-card form { display: grid; gap: .55rem; }
.login-card label { font-size: .85rem; font-weight: 700; }
.login-card input { border: 1px solid var(--line); border-radius: 8px; padding: .7rem .8rem; }
.login-card button { margin-top: .6rem; border: 0; border-radius: 8px; padding: .75rem; background: var(--blue-600); color: white; font-weight: 750; cursor: pointer; }
.alert { background: #ffeded; color: var(--danger); border-radius: 8px; padding: .7rem .8rem; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 1.25rem; color: white; background: var(--navy-950); }
.brand { font-weight: 750; }
.topbar-actions { display: flex; align-items: center; gap: .55rem; }
.topbar form { margin: 0; }
.btn-ghost { display: inline-block; border: 1px solid rgb(255 255 255 / .4); border-radius: 8px; padding: .42rem .75rem; color: white; background: transparent; text-decoration: none; cursor: pointer; }
.btn-ghost:hover { background: rgb(255 255 255 / .1); }
.wrap { max-width: 92rem; margin: 0 auto; padding: 1.25rem; }

.config-card { display: grid; grid-template-columns: minmax(13rem, .6fr) minmax(20rem, 1fr); gap: 1rem 2rem; align-items: start; margin-bottom: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: 0 2px 10px rgb(8 34 55 / .05); }
.config-copy h2 { margin: 0; color: var(--navy-950); font-size: 1rem; }
.config-copy p { margin: .3rem 0 0; color: var(--muted); font-size: .8rem; line-height: 1.45; }
.config-card form { display: grid; gap: .4rem; }
.config-card label { font-size: .8rem; font-weight: 750; }
.config-controls { display: flex; gap: .55rem; }
.config-controls input { width: min(100%, 20rem); border: 1px solid var(--line); border-radius: 8px; padding: .58rem .72rem; }
.config-controls input:focus-visible { outline: 3px solid var(--blue-600); outline-offset: 2px; }
.config-controls button { border: 0; border-radius: 8px; padding: .58rem .85rem; color: var(--white); background: var(--blue-600); font-weight: 750; cursor: pointer; }
.config-help, .config-success, .config-error { margin: 0; font-size: .75rem; line-height: 1.45; }
.config-help { color: var(--muted); }
.config-success { color: #176c3b; font-weight: 700; }
.config-error { color: var(--danger); font-weight: 700; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .75rem; }
.stat { display: grid; gap: .1rem; padding: .9rem; text-align: center; background: var(--white); border-radius: var(--radius); box-shadow: 0 2px 10px rgb(8 34 55 / .05); }
.stat-number { color: var(--blue-600); font-size: 1.55rem; font-weight: 800; }
.stat span:last-child { color: var(--muted); font-size: .8rem; }
.filters { display: flex; gap: .7rem; margin: 1rem 0; flex-wrap: wrap; }
.filters input, .filters select { border: 1px solid var(--line); border-radius: 8px; background: var(--white); padding: .58rem .72rem; }
.filters input { flex: 1; min-width: 17rem; }
.results-toolbar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 0 0 .5rem; }
.result-count { margin: 0; color: var(--muted); font-size: .8rem; }
.btn-export { border: 1px solid var(--blue-600); border-radius: 7px; padding: .38rem .7rem; color: var(--blue-600); background: var(--white); font-size: .8rem; font-weight: 700; text-decoration: none; }
.btn-export:hover { color: var(--white); background: var(--blue-600); }
.empty { padding: 2rem; text-align: center; color: var(--muted); background: white; border-radius: var(--radius); }

.table-scroll { overflow-x: auto; background: white; border-radius: var(--radius); box-shadow: 0 2px 12px rgb(8 34 55 / .06); }
.table-scroll:focus-visible { outline: 3px solid var(--blue-600); outline-offset: 3px; }
.scroll-hint { display: none; margin: 0 0 .45rem; color: var(--muted); font-size: .78rem; }
.leads { width: 100%; border-collapse: collapse; font-size: .86rem; }
.leads th { padding: .7rem .75rem; text-align: left; color: var(--muted); background: #edf3f6; text-transform: uppercase; letter-spacing: .035em; font-size: .72rem; }
.leads td { padding: .75rem; border-top: 1px solid #e7edf0; vertical-align: top; }
.cell-meta { min-width: 10rem; color: var(--muted); white-space: nowrap; }
.cell-meta time, .form-badge { display: block; }
.form-badge { width: fit-content; margin-top: .3rem; padding: .15rem .45rem; border-radius: 999px; color: var(--navy-800); background: var(--blue-100); font-size: .72rem; }
.cell-name { min-width: 9rem; font-weight: 700; }
.cell-contact { display: grid; min-width: 13rem; gap: .2rem; }
.cell-contact a { color: var(--blue-600); text-decoration: none; overflow-wrap: anywhere; }
.cell-contact a:hover { text-decoration: underline; }
.cell-content { min-width: 12rem; max-width: 24rem; }
.cell-content summary { color: var(--blue-600); cursor: pointer; }
.cell-content p { white-space: pre-wrap; }
.additional-data-scroll { max-height: 16rem; margin-top: .55rem; padding-right: .2rem; overflow-x: hidden; overflow-y: auto; }
.additional-data-scroll:focus-visible { outline: 3px solid var(--blue-600); outline-offset: 2px; }
.additional-data-list { display: grid; gap: .4rem; margin: 0; }
.additional-data-item { display: grid; grid-template-columns: minmax(7rem, .75fr) minmax(0, 1.25fr); gap: .55rem; padding: .5rem .6rem; border: 1px solid #e2e9ed; border-radius: 7px; background: #f5f8fa; }
.additional-data-item dt { min-width: 0; color: var(--muted); font-size: .7rem; font-weight: 750; line-height: 1.4; overflow-wrap: anywhere; }
.additional-data-item dd { min-width: 0; margin: 0; color: var(--ink); font-size: .76rem; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.attachment-link { display: grid; gap: .12rem; width: fit-content; margin-top: .55rem; padding: .45rem .6rem; border: 1px solid var(--blue-600); border-radius: 7px; color: var(--blue-600); background: var(--white); font-weight: 750; text-decoration: none; }
.attachment-link:hover { color: var(--white); background: var(--blue-600); }
.attachment-link:focus-visible { outline: 3px solid var(--blue-600); outline-offset: 3px; }
.attachment-link small { max-width: 17rem; color: var(--muted); font-size: .68rem; font-weight: 500; overflow-wrap: anywhere; }
.attachment-link:hover small { color: inherit; }
.status { border: 1px solid var(--line); border-radius: 999px; padding: .35rem .5rem; font-size: .8rem; font-weight: 700; }
.status-nuevo { background: #fff4cf; border-color: #d6b54c; }
.status-contactado { background: #def0ff; border-color: #71abd6; }
.status-no_contesta { background: #f0e5fa; border-color: #aa82cf; }
.status-convertido { background: #def5e7; border-color: #62ad7e; }
.status-descartado { background: #eceff1; border-color: #aab2b7; color: var(--muted); }
.updated { display: block; margin-top: .25rem; color: var(--muted); font-size: .67rem; }
.cell-notes form { display: grid; gap: .3rem; min-width: 12rem; }
.cell-notes textarea { width: 100%; padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 7px; resize: vertical; }
.cell-notes button { justify-self: end; padding: .3rem .65rem; border: 0; border-radius: 6px; color: white; background: var(--blue-600); cursor: pointer; font-size: .77rem; }
.cell-actions { min-width: 7rem; }
.cell-actions form { margin: 0; }
.delete-control { position: relative; }
.delete-control summary { list-style: none; }
.delete-control summary::-webkit-details-marker { display: none; }
.btn-delete { display: inline-block; padding: .35rem .6rem; border: 1px solid #cf8d8d; border-radius: 6px; color: var(--danger); background: var(--white); cursor: pointer; font-size: .77rem; font-weight: 700; }
.btn-delete:hover { border-color: var(--danger); color: var(--white); background: var(--danger); }
.btn-delete:focus-visible { outline: 3px solid var(--danger); outline-offset: 2px; }
.delete-confirm { display: grid; width: 15rem; gap: .55rem; margin-top: .55rem; padding: .7rem; border: 1px solid #cf8d8d; border-radius: 8px; color: var(--navy-950); background: #fff8f8; box-shadow: 0 8px 22px rgb(8 34 55 / .12); }
.delete-confirm p { margin: 0; font-size: .76rem; line-height: 1.45; }
.btn-delete-confirm { width: 100%; padding: .45rem .65rem; border: 1px solid var(--danger); border-radius: 6px; color: var(--white); background: var(--danger); cursor: pointer; font-size: .77rem; font-weight: 750; }
.btn-delete-confirm:hover { background: #7e2525; }
.btn-delete-confirm:focus-visible { outline: 3px solid var(--navy-950); outline-offset: 2px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 1rem 0; color: var(--muted); }
.pager a { color: var(--blue-600); font-weight: 700; }

@media (max-width: 640px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .wrap { padding: .75rem; }
  .filters { display: grid; }
  .filters input { min-width: 0; }
  .scroll-hint { display: block; }
  .config-card { grid-template-columns: 1fr; }
  .config-controls { align-items: stretch; flex-direction: column; }
  .config-controls input { width: 100%; }
  .additional-data-item { grid-template-columns: 1fr; gap: .15rem; }
}
