:root {
  --green: #0f4d35;
  --green-2: #1f7a4f;
  --green-soft: #e3f1ea;
  --lime: #c8ce25;
  --lime-soft: #f4f6cf;
  --bg: #f4f5f2;
  --surface: #ffffff;
  --ink: #141614;
  --ink-2: #4f554f;
  --ink-3: #8a908a;
  --line: #e3e6e1;
  --line-2: #d2d6d0;
  --pos: #1f7a4f;
  --neg: #c0392b;
  --blue: #2a78d6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 20, .05), 0 2px 10px rgba(20, 22, 20, .04);
  --sidebar: 236px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg); }
a { color: var(--green-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 700; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 10px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
h3.mt { margin-top: 18px; }
p { margin: 0 0 10px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.inline { display: inline; }
.hint { cursor: help; color: var(--ink-3); }
.note { background: var(--lime-soft); border-left: 3px solid var(--lime); padding: 8px 10px; border-radius: 6px; }
ul.tight { margin: 0; padding-left: 18px; }
ul.tight li { margin: 2px 0; }

/* ---------- layout ---------- */
body.app { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--green); color: #e9f2ec; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--lime), #8fb531); flex: none; position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--green); }
.brand-name { font-weight: 700; font-size: 14px; line-height: 1.1; color: #fff; }
.brand-sub { font-size: 11px; color: #a9c7b6; margin-top: 2px; }
.brand.big .brand-mark { width: 40px; height: 40px; }
.brand.big .brand-name { font-size: 17px; color: var(--ink); }
.brand.big .brand-sub { color: var(--ink-3); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: #d6e6dc; font-weight: 500; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.sidebar nav a.on { background: rgba(200, 206, 37, .16); color: #fff; }
.sidebar nav a.on .ic { color: var(--lime); }
.sidebar nav .ic { width: 18px; text-align: center; opacity: .85; font-size: 13px; }
.nav-sep { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #8fb09c; padding: 14px 10px 4px; }
.sidebar-foot { margin-top: auto; border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 12px; display: flex; align-items: center; gap: 8px; }
.sidebar-foot .user { display: flex; align-items: center; gap: 10px; color: #fff; flex: 1; padding: 6px; border-radius: 8px; }
.sidebar-foot .user:hover, .sidebar-foot .user.on { background: rgba(255, 255, 255, .07); text-decoration: none; }
.sidebar-foot .user > span:last-child { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 11px; color: #a9c7b6; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--lime); color: var(--green); font-weight: 700; display: grid; place-items: center; flex: none; }
.btn-link { background: none; border: 0; color: inherit; cursor: pointer; font: inherit; padding: 4px 6px; opacity: .8; }
.btn-link:hover { opacity: 1; text-decoration: underline; }
.sidebar-foot .btn-link { color: #d6e6dc; font-size: 12px; }
.topbar { display: none; }
main { padding: 26px 32px 60px; max-width: 1180px; width: 100%; }
main.wide { max-width: 1560px; }
body.anon main { max-width: none; padding: 0; }

/* ---------- page head / filters ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-2); margin: 0; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type=search] { min-width: 240px; flex: 1; max-width: 360px; }
.filters select { max-width: 200px; }
.filters .fl { display: flex; flex-direction: column; font-size: 11px; color: var(--ink-3); gap: 3px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg a { padding: 7px 12px; color: var(--ink-2); font-weight: 500; font-size: 13px; }
.seg a.on { background: var(--green); color: #fff; }
.seg a:hover { text-decoration: none; }

/* ---------- cards / grids ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.table-card { padding: 0; overflow: auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.dl dt { color: var(--ink-3); font-size: 12px; }
.dl dd { margin: 0; }
.notes { white-space: pre-wrap; }
details.card summary { cursor: pointer; font-weight: 600; }

/* ---------- forms / buttons ---------- */
label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 10px; font-weight: 500; }
label input, label select, label textarea { margin-top: 4px; }
input, select, textarea, button { font: inherit; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=number], input[type=date], input[type=file], input:not([type]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: #fff; color: var(--ink); min-height: 36px;
}
.filters input, .filters select { width: auto; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(31, 122, 79, .35); outline-offset: 1px; border-color: var(--green-2); }
textarea { resize: vertical; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); font-weight: 500; cursor: pointer; white-space: nowrap; line-height: 1.2; }
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: #0b3d2a; border-color: #0b3d2a; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--neg); border-color: #e9c4bf; }
.btn-danger:hover { background: #fdf3f1; }
.btn-block { width: 100%; justify-content: center; }
.inline-select { width: auto; min-height: 30px; padding: 4px 26px 4px 8px; font-size: 12.5px; border-radius: 7px; background-color: #fff; max-width: 190px; }
.fase-select, .clasif-select { font-weight: 500; }
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; font-weight: 500; }
.flash-ok { background: var(--green-soft); border-color: #bfe0cd; color: #0f4d35; }
.flash-error { background: #fdf0ee; border-color: #f0c5bf; color: #9b2d21; }
.flash-info { background: var(--lime-soft); border-color: #e2e68a; color: #4d5208; }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 600; background: #fafbf9; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
.tbl thead th a { color: inherit; }
.tbl tfoot th { font-weight: 600; background: #fafbf9; border-top: 2px solid var(--line-2); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tbody tr:hover { background: #f6f8f5; }
.tbl-dense th, .tbl-dense td { padding: 6px 10px; font-size: 12.5px; }
.tbl .empty, .empty { color: var(--ink-3); text-align: center; padding: 22px; font-style: italic; }
.row-late td:first-child { border-left: 3px solid var(--neg); }
.table-scroll { overflow: auto; }
.ventas-tbl { min-width: 1180px; }
.ventas-tbl input.cell { width: 84px; min-height: 28px; padding: 3px 6px; font-size: 12px; text-align: right; border-radius: 6px; }

/* ---------- badges ---------- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.b-clave { background: #e8e3fb; color: #4b3aa5; }
.b-crec { background: var(--green-soft); color: #0f4d35; }
.b-decr { background: #fdebe8; color: #a12f22; }
.b-recu { background: #fff1dc; color: #8a5200; }
.b-nueva { background: #dcefff; color: #1a4f8f; }
.b-pros { background: #eef0ec; color: #4f554f; }
.b-muted { background: #eef0ec; color: #8a908a; }
.cat { display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.cat-A { background: var(--green); color: #fff; }
.cat-B { background: var(--green-soft); color: var(--green); }
.cat-C { background: #eef0ec; color: var(--ink-2); }
.fase { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 12px; background: #eef0ec; }
.fase.f9, .fase-select.f9 { background: var(--green-soft); }
.fase.f0 { color: var(--ink-3); }

/* ---------- stepper ---------- */
.stepper { display: grid; grid-template-columns: repeat(9, 1fr); gap: 4px; margin-bottom: 12px; }
.step { display: block; }
.step button, .step > span { display: block; width: 100%; }
.step button { background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.step .n { display: block; height: 6px; border-radius: 3px; background: var(--line-2); margin-bottom: 6px; font-size: 0; }
.step .l { display: block; font-size: 11px; color: var(--ink-3); line-height: 1.2; }
.step.done .n { background: #9ec9b2; }
.step.cur .n { background: var(--green); }
.step.cur .l { color: var(--green); font-weight: 600; }
.step button:hover .n { background: var(--lime); }

/* ---------- kanban ---------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: 236px; gap: 10px; overflow-x: auto; padding-bottom: 12px; }
.kcol { background: #eceeea; border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.khead { padding: 10px 12px 8px; font-weight: 600; font-size: 12.5px; position: relative; }
.khead .kn { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: var(--green); color: #fff; font-size: 11px; margin-right: 4px; }
.kcount { float: right; color: var(--ink-3); font-weight: 500; }
.ksum { font-size: 11px; color: var(--ink-3); font-weight: 500; margin-top: 2px; }
.kbody { padding: 0 8px 8px; overflow-y: auto; flex: 1; min-height: 60px; }
.kbody.over { outline: 2px dashed var(--green-2); outline-offset: -4px; border-radius: 8px; }
.kcard { display: block; background: #fff; border-radius: 8px; padding: 10px 11px; margin-bottom: 8px; border: 1px solid var(--line); color: var(--ink); cursor: grab; }
.kcard:hover { text-decoration: none; border-color: var(--green-2); }
.kcard.dragging { opacity: .5; }
.kname { font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.kmeta, .kmeta2 { font-size: 11.5px; color: var(--ink-2); }
.kmeta2 { margin-top: 4px; }

/* ---------- KPIs / dashboard ---------- */
.dash-section { margin-bottom: 26px; }
.sec-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 0 0 10px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.k-label { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.k-val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; margin: 2px 0; font-variant-numeric: tabular-nums; }
.k-sub { font-size: 12px; color: var(--ink-2); }
.kpis-inline { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
.chart { position: relative; }
.pend-list { list-style: none; margin: 0; padding: 0; }
.pend-list li { padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.pend-list .pd { display: inline-block; font-variant-numeric: tabular-nums; color: var(--ink-3); margin-right: 6px; font-size: 12px; }
.pend-list li.late .pd { color: var(--neg); font-weight: 600; }
.pend-list li.today .pd { color: var(--green-2); font-weight: 600; }

/* ---------- timeline ---------- */
.act-form { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 14px; background: #fafbf9; }
.act-row { display: grid; grid-template-columns: 170px 150px 1fr; gap: 8px; margin-bottom: 8px; }
.act-row:last-child { grid-template-columns: 1fr 150px auto; margin-bottom: 0; }
.act-row input, .act-row select { width: 100%; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 16px; border-left: 2px solid var(--line-2); position: relative; margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--green-2); border: 2px solid #fff; }
.timeline li.late::before { background: var(--neg); }
.timeline.compact li { padding: 7px 0 7px 14px; }
.tl-head { font-size: 12px; margin-bottom: 2px; }
.tl-type { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #eef0ec; color: var(--ink-2); }
.t-llamada { background: #dcefff; color: #1a4f8f; }
.t-correo, .t-whatsapp { background: var(--lime-soft); color: #4d5208; }
.t-reunion, .t-visita { background: var(--green-soft); color: #0f4d35; }
.t-propuesta { background: #e8e3fb; color: #4b3aa5; }
.t-charla, .t-brigada { background: #fff1dc; color: #8a5200; }
.tl-body { white-space: pre-wrap; }
.tl-next { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; }
.tl-next.done { text-decoration: line-through; color: var(--ink-3); }
.tl-del { float: right; }
.hist { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.hist li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.danger-zone form { display: inline-block; margin: 0 6px 6px 0; }

/* ---------- modal ---------- */
.modal { display: none; position: fixed; inset: 0; background: rgba(10, 20, 14, .45); z-index: 50; padding: 20px; overflow: auto; }
.modal.open { display: flex; align-items: flex-start; justify-content: center; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 760px; padding: 20px 22px; margin: 20px auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-box.small { max-width: 460px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-head .x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--ink-3); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.modal h3 { margin-top: 10px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 10% -10%, var(--lime-soft), transparent), radial-gradient(900px 500px at 110% 110%, var(--green-soft), transparent), var(--bg); padding: 20px; }
.login-card { background: #fff; width: 100%; max-width: 400px; padding: 30px 30px 24px; border-radius: 16px; box-shadow: 0 10px 40px rgba(15, 77, 53, .12); border: 1px solid var(--line); }
.login-card h1 { margin: 10px 0 14px; }
.login-foot { font-size: 12px; color: var(--ink-3); margin: 14px 0 0; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1, .grid-main { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  body.app { display: block; }
  .topbar { display: flex; align-items: center; gap: 12px; background: var(--green); color: #fff; padding: 12px 16px; position: sticky; top: 0; z-index: 40; }
  .topbar-title { font-weight: 700; }
  .menu-btn { background: none; border: 0; color: #fff; font-size: 20px; cursor: pointer; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; height: 100vh; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  main { padding: 16px 16px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: repeat(3, 1fr); }
  .act-row, .act-row:last-child { grid-template-columns: 1fr; }
  .filters input[type=search] { min-width: 0; max-width: none; width: 100%; }
  .page-head { flex-direction: column; }
}
