:root {
  --navy: #12232d;
  --ink: #172a34;
  --sand: #f4f0e8;
  --paper: #fffdf8;
  --terra: #cd543b;
  --blue: #075577;
  --green: #31705a;
  --amber: #b8781e;
  --red: #a8433c;
  --muted: #66767f;
  --line: #ddd5c8;
  --sidebar: 236px;
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--sand); color: var(--ink); }
body { margin: 0; min-height: 100vh; background: var(--sand); }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; color: var(--navy); }
h1 { font-size: clamp(1.7rem, 3vw, 2.6rem); line-height: 1.08; margin-bottom: 0; }
h2 { font-size: 1.35rem; line-height: 1.2; margin-bottom: 0.8rem; }
small { display: block; color: var(--muted); }

.app-shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy); color: #fff; padding: 26px 18px; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 0 8px 26px; border-bottom: 1px solid rgba(255,255,255,.13); }
.brand-mark { width: 42px; height: 42px; border-radius: 9px; display: inline-grid; place-items: center; flex: 0 0 auto; background: linear-gradient(145deg, var(--terra), #9f3e2c); color: #fff; font: 700 22px Georgia, serif; }
.brand strong, .brand small { display: block; color: #fff; }
.brand strong { letter-spacing: .1em; font-size: .82rem; }
.brand small { margin-top: 4px; opacity: .66; font-size: .67rem; letter-spacing: .14em; }
.sidebar nav { display: grid; gap: 7px; padding-top: 24px; }
.sidebar nav a { color: rgba(255,255,255,.72); text-decoration: none; padding: 12px 13px; border-radius: 8px; display: flex; gap: 12px; align-items: center; font-size: .88rem; font-weight: 700; }
.sidebar nav a span { color: #84adbe; font-size: .65rem; letter-spacing: .12em; }
.sidebar nav a:hover, .sidebar nav a.is-active { color: #fff; background: rgba(255,255,255,.095); }
.sidebar nav a.is-active { box-shadow: inset 3px 0 0 var(--terra); }
.sidebar-foot { margin-top: auto; padding: 20px 8px 0; border-top: 1px solid rgba(255,255,255,.13); display: grid; gap: 10px; }
.sidebar-foot a, .sidebar-foot button { color: rgba(255,255,255,.68); background: none; border: 0; padding: 0; font-size: .75rem; text-decoration: none; cursor: pointer; }
.sidebar-foot a:hover, .sidebar-foot button:hover { color: #fff; }

.main { min-width: 0; padding: 32px clamp(22px, 4vw, 58px) 64px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.topbar p, .eyebrow { margin-bottom: 7px; color: var(--blue); font-size: .67rem; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.user-chip { display: flex; align-items: center; gap: 10px; background: var(--paper); border: 1px solid var(--line); padding: 8px 12px 8px 8px; border-radius: 999px; }
.user-chip > span { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--blue); color: #fff; font-weight: 800; }
.user-chip strong, .user-chip a { display: block; }
.user-chip strong { font-size: .75rem; }
.user-chip a { color: var(--blue); font-size: .68rem; margin-top: 2px; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.metric { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 20px; min-height: 126px; }
.metric span { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { display: block; margin: 15px 0 8px; font: 700 2rem Georgia, serif; color: var(--navy); }
.metric small { font-size: .7rem; }
.split-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr); gap: 20px; margin-top: 20px; }
.panel-card, .form-card, .table-card { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 24px; min-width: 0; }
.table-card { padding: 0; overflow: auto; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.card-head a:not(.button) { color: var(--blue); font-size: .75rem; font-weight: 700; }
.funnel { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.funnel a { background: #eef3f5; border-radius: 8px; padding: 15px 10px; text-decoration: none; text-align: center; border-bottom: 3px solid transparent; }
.funnel a:hover { border-color: var(--terra); }
.funnel strong { display: block; color: var(--navy); font: 700 1.45rem Georgia, serif; }
.funnel span { color: var(--muted); font-size: .67rem; }
.task-list, .audit-list { padding: 0; margin: 0; list-style: none; display: grid; gap: 0; }
.task-list li, .audit-list li { padding: 12px 0; border-bottom: 1px solid #ece5db; }
.task-list li:last-child, .audit-list li:last-child { border: 0; }
.task-list span, .task-list a, .task-list time { display: block; }
.task-list span { font-size: .75rem; color: var(--muted); }
.task-list a { font-weight: 700; text-decoration: none; margin: 3px 0; }
.task-list time, .audit-list small { color: var(--muted); font-size: .67rem; }
.audit-list span { font-weight: 700; font-size: .78rem; }

.property-mini-list { display: grid; }
.property-mini-list > a { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #ece5db; text-decoration: none; }
.property-mini-list > a:last-child { border: 0; }
.property-mini-list img { width: 54px; height: 48px; object-fit: cover; border-radius: 6px; }
.property-mini-list strong, .property-mini-list small { display: block; }
.property-mini-list strong { font-size: .79rem; }
.property-mini-list small { margin-top: 4px; font-size: .67rem; }
.status, .badge, .stage { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 5px 9px; font-size: .62rem; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; background: #e7eef1; color: var(--blue); white-space: nowrap; }
.status.live, .badge.green { background: #e2efe9; color: var(--green); }
.status.draft, .badge.amber { background: #fff0d6; color: var(--amber); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin: 0 0 20px; }
.page-actions p { color: var(--muted); max-width: 650px; margin-bottom: 0; }
.page-actions > div { display: flex; align-items: center; gap: 9px; }
.page-actions form { margin: 0; }
.button { min-height: 40px; border-radius: 7px; border: 1px solid transparent; padding: 10px 16px; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; font-size: .75rem; font-weight: 800; cursor: pointer; }
.button.primary { color: #fff; background: var(--terra); }
.button.primary:hover { background: #b84430; }
.button.ghost { color: var(--blue); border-color: #a7bdc7; background: transparent; }
.button.danger { color: var(--red); border-color: #d9a7a2; background: #fff; }
.cms-property-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.cms-property { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: grid; grid-template-columns: minmax(160px, .75fr) minmax(0, 1.25fr); }
.cms-property > img { width: 100%; height: 100%; min-height: 270px; object-fit: cover; }
.cms-property > div { padding: 24px; display: flex; flex-direction: column; align-items: flex-start; }
.cms-property h2 { margin-top: 16px; }
.cms-property p { color: var(--muted); }
.cms-property > div > strong { color: var(--terra); margin-bottom: 7px; }
.cms-property > div > small { margin-bottom: 22px; }
.cms-property .button { margin-top: auto; }

.editor-form { display: grid; gap: 18px; }
.form-grid { display: grid; gap: 17px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.stack { display: grid; gap: 15px; }
label { display: grid; gap: 7px; color: var(--ink); font-size: .73rem; font-weight: 800; }
input, select, textarea { width: 100%; color: var(--ink); background: #fff; border: 1px solid #cfc6b7; border-radius: 7px; padding: 11px 12px; outline: none; font-weight: 400; }
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(7,85,119,.1); }
.check-row { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 20px; }
.check-row label { display: flex; align-items: center; gap: 8px; }
.check-row input { width: 17px; height: 17px; }
.field-help { color: var(--muted); font-size: .7rem; line-height: 1.45; }
.upload-button { position: relative; display: inline-flex; align-items: center; justify-content: center; width: auto; color: var(--blue); border: 1px dashed #81a2b0; border-radius: 7px; padding: 10px 14px; cursor: pointer; }
.upload-button input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-status { min-height: 20px; color: var(--green); font-size: .75rem; }
.sticky-actions { position: sticky; bottom: 12px; z-index: 5; display: flex; justify-content: flex-end; gap: 9px; padding: 13px; background: rgba(244,240,232,.94); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(8px); }

.stage-filter { display: flex; gap: 8px; overflow: auto; padding: 0 0 13px; }
.stage-filter a { flex: 0 0 auto; color: var(--muted); background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; text-decoration: none; font-size: .7rem; font-weight: 700; }
.stage-filter a.active { color: #fff; background: var(--blue); border-color: var(--blue); }
.stage-filter b { margin-left: 5px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 15px 18px; text-align: left; border-bottom: 1px solid #ece5db; vertical-align: top; }
th { color: var(--muted); background: #faf7f1; font-size: .64rem; text-transform: uppercase; letter-spacing: .08em; }
td { font-size: .76rem; }
td small { margin-top: 5px; }
.table-title { display: block; font-weight: 800; text-decoration: none; }
.stage { background: #e7eef1; color: var(--blue); }
.stage-negociacion { background: #f4e2de; color: var(--terra); }
.stage-cerrado, .stage-calificado { background: #e2efe9; color: var(--green); }
.stage-perdido { background: #ece8e1; color: var(--muted); }
.lead-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(290px, .65fr); gap: 20px; align-items: start; }
.activity-panel { display: grid; gap: 18px; }
.timeline { padding: 4px 8px; }
.timeline article { position: relative; display: grid; grid-template-columns: 16px 1fr; gap: 12px; padding: 0 0 22px; }
.timeline article::before { content: ""; position: absolute; left: 5px; top: 11px; bottom: 0; width: 1px; background: var(--line); }
.timeline article:last-child::before { display: none; }
.timeline article > span { position: relative; z-index: 1; width: 11px; height: 11px; margin-top: 3px; border-radius: 50%; background: var(--terra); }
.timeline p { margin: 5px 0; line-height: 1.4; font-size: .76rem; white-space: pre-line; }
.timeline small { font-size: .65rem; }

.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; }
.media-grid figure { margin: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.media-grid img { width: 100%; height: 170px; object-fit: cover; }
.media-grid figcaption { display: grid; gap: 8px; padding: 10px; }
.media-grid code { font-size: .63rem; overflow-wrap: anywhere; }
.media-grid button { justify-self: start; color: var(--blue); background: none; border: 0; padding: 0; font-size: .68rem; cursor: pointer; }
.users-layout { grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); }
.credential-result { background: var(--navy); color: #fff; border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.credential-result .eyebrow { color: #9fc3d2; }
.credential-result strong { display: block; }
.credential-result code { display: inline-block; margin: 12px 0; padding: 9px 12px; background: rgba(255,255,255,.1); border-radius: 6px; font-size: 1rem; }
.credential-result p:last-child { margin: 0; color: #d8e4e8; font-size: .75rem; }
.narrow { max-width: 610px; margin: 20px auto; }

.notice { border-radius: 9px; padding: 13px 16px; margin: 0 0 20px; font-size: .78rem; font-weight: 700; }
.notice.success { color: var(--green); background: #e2efe9; border: 1px solid #b7d6c7; }
.notice.error { color: var(--red); background: #f5e4e1; border: 1px solid #e1b5ae; }
.notice.warning { color: var(--amber); background: #fff0d6; border: 1px solid #edd09a; }
.empty { grid-column: 1 / -1; min-height: 180px; display: grid; place-items: center; align-content: center; gap: 7px; color: var(--muted); text-align: center; }
.empty.compact { min-height: 90px; }

.login-page { display: grid; place-items: center; padding: 24px; background: linear-gradient(135deg, var(--navy) 0 45%, var(--sand) 45% 100%); }
.login-card { width: min(100%, 470px); background: var(--paper); border-radius: 14px; padding: clamp(28px, 6vw, 48px); box-shadow: 0 28px 80px rgba(0,0,0,.25); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 46px; }
.login-brand strong, .login-brand small { display: block; }
.login-brand small { color: var(--muted); margin-top: 3px; font-size: .7rem; }
.login-card h1 { font-size: 2.25rem; margin-bottom: 28px; }
.login-card .help { color: var(--muted); margin: 18px 0 0; font-size: .7rem; line-height: 1.45; }

@media (max-width: 1150px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .cms-property-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar: 86px; }
  .sidebar { padding-inline: 12px; }
  .brand { justify-content: center; padding-inline: 0; }
  .brand > span:last-child, .sidebar nav a:not(.is-active) > span + *, .sidebar nav a { font-size: 0; }
  .sidebar nav a { justify-content: center; padding: 13px 7px; }
  .sidebar nav a span { font-size: .65rem; }
  .sidebar-foot { display: none; }
  .split-grid, .lead-layout, .users-layout { grid-template-columns: 1fr; }
  .funnel { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 680px) {
  :root { --sidebar: 0px; }
  .app-shell { display: block; }
  .sidebar { position: static; width: auto; height: auto; padding: 12px 14px; flex-direction: row; align-items: center; overflow: auto; }
  .brand { padding: 0 16px 0 0; border: 0; }
  .brand-mark { width: 35px; height: 35px; }
  .sidebar nav { display: flex; padding: 0; gap: 5px; }
  .sidebar nav a { min-width: 44px; }
  .main { padding: 24px 16px 50px; }
  .topbar { align-items: flex-start; }
  .user-chip { padding-right: 8px; }
  .user-chip div { display: none; }
  .metrics-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric { min-height: 110px; padding: 15px; }
  .metric strong { font-size: 1.55rem; }
  .funnel { grid-template-columns: repeat(2, 1fr); }
  .form-grid.two { grid-template-columns: 1fr; }
  .form-grid .wide { grid-column: auto; }
  .cms-property { grid-template-columns: 1fr; }
  .cms-property > img { height: 220px; min-height: 0; }
  .page-actions { align-items: flex-start; flex-direction: column; }
  .page-actions > div { width: 100%; }
  .page-actions .button { flex: 1; }
  .media-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 430px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: 1fr; }
  .sticky-actions { flex-wrap: wrap; }
  .sticky-actions .button { flex: 1; }
}

