/* KOKO Gestión — estilos. Diseño simple, legible y responsive. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e4ea;
  --primary: #1f6feb;
  --primary-dark: #1857bd;
  --danger: #d33;
  --ok: #1a7f37;
  --amber: #b45309;
  --sidebar-w: 220px;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
}

h1 { font-size: 1.5rem; margin: 0 0 .8rem; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; }
a { color: var(--primary); text-decoration: none; }
small, .muted { color: var(--muted); }
.pre { white-space: pre-wrap; word-break: break-word; }

/* ---------- Layout ---------- */
.main { padding: 1rem; max-width: 1400px; }
.main-auth { max-width: none; padding: 0; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: #171c26; color: #fff; display: flex; flex-direction: column;
  padding: 1rem .6rem; gap: .2rem;
}
.sidebar .brand { font-weight: 700; font-size: 1.1rem; padding: .3rem .6rem 1rem; }
.sidebar nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.nav-link {
  display: block; padding: .65rem .8rem; border-radius: 8px;
  color: #cfd6e4; font-weight: 500;
}
.nav-form { margin: 0; }
.nav-form .nav-link {
  width: 100%; border: 0; background: none; text-align: left;
  font: inherit; cursor: pointer;
}
.nav-link:hover { background: #232a38; color: #fff; }
.nav-link.active { background: var(--primary); color: #fff; }
.sidebar-bottom { display: flex; flex-direction: column; gap: .15rem; }
.sidebar-bottom .me { padding: .5rem .8rem; color: #cfd6e4; font-size: .9rem; }

.bottomnav, .more-menu { display: none; }
.more-menu[hidden] { display: none !important; }

@media (min-width: 900px) {
  .main { margin-left: var(--sidebar-w); }
}
@media (max-width: 899px) {
  .sidebar { display: none; }
  .main { padding-bottom: 4.5rem; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: #171c26; padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom));
  }
  .bn {
    flex: 1; text-align: center; color: #cfd6e4; font-size: .8rem;
    padding: .7rem .2rem; border: 0; background: none; border-radius: 8px; font-weight: 600;
  }
  .bn.active { color: #fff; background: var(--primary); }
  .more-menu {
    position: fixed; bottom: 3.6rem; right: .5rem; z-index: 60;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,.18); display: flex; flex-direction: column; min-width: 190px;
  }
  .more-menu a, .more-menu button {
    padding: .9rem 1rem; border: 0; border-bottom: 1px solid var(--border);
    color: var(--text); background: none; text-align: left; font: inherit; cursor: pointer;
  }
  .more-menu a:last-child, .more-menu form:last-child button { border-bottom: 0; }
  .more-form { margin: 0; }
}

/* ---------- Componentes ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem; margin-bottom: 1rem;
}

.btn {
  display: inline-block; padding: .6rem 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: .95rem; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: #c5c9d4; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-small { padding: .35rem .7rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.btn-x { border: 0; background: none; color: var(--danger); font-size: 1.1rem; cursor: pointer; padding: 0 .3rem; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.page-head h1, .page-head h2 { margin: 0; }

.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: .8rem; font-weight: 500; }
.flash-ok { background: #e6f4ea; color: var(--ok); border: 1px solid #b9e0c4; }
.flash-error { background: #fdecec; color: var(--danger); border: 1px solid #f5c2c2; }

/* Formularios */
label { display: block; margin-bottom: .7rem; font-weight: 600; font-size: .92rem; }
input, select, textarea {
  width: 100%; padding: .65rem .7rem; margin-top: .25rem;
  border: 1px solid var(--border); border-radius: 8px; font-size: 1rem; font-family: inherit;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
.form-narrow { max-width: 640px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .6rem; align-items: end; }
.form-2col { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .2rem .8rem; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
label.check input { width: 1.2rem; height: 1.2rem; margin: 0; }
.inline-form { display: inline-flex; gap: .4rem; align-items: center; }
.inline-form input, .inline-form select { width: auto; margin-top: 0; }
.status-form select { max-width: 260px; }

/* Insignias */
.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; vertical-align: middle;
}
.badge-baja { background: #e8eaf0; color: #4b5563; }
.badge-media { background: #dbeafe; color: #1e50a0; }
.badge-alta { background: #ffedd5; color: var(--amber); }
.badge-urgente { background: #fee2e2; color: #b91c1c; }
.badge-cat { background: #ecfdf5; color: #047857; }
.badge-type { background: #ede9fe; color: #6d28d9; }
.badge-muted { background: #e8eaf0; color: var(--muted); }

/* Login */
.auth-box {
  max-width: 400px; margin: 8vh auto; background: var(--card);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem;
}
.auth-box h1 { text-align: center; }
.auth-box h2 { color: var(--muted); font-weight: 500; text-align: center; }
.auth-links { text-align: center; }

/* Panel */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .9rem 1rem; color: var(--text); font-weight: 600;
}
.stat-n { display: block; font-size: 1.9rem; font-weight: 800; color: var(--primary); }
.stat-red .stat-n { color: var(--danger); }
.stat-amber .stat-n { color: var(--amber); }

.row-item {
  display: block; padding: .65rem .5rem; border-bottom: 1px solid var(--border); color: var(--text);
}
.row-item:last-child { border-bottom: 0; }
.row-item:hover { background: #f8f9fb; }
.row-meta { display: block; font-size: .84rem; color: var(--muted); margin-top: .15rem; }
.card-row { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .5rem; padding: .8rem; }
.card-row.overdue { border-left: 4px solid var(--danger); }

/* Kanban */
.kanban {
  display: flex; gap: .7rem; overflow-x: auto; padding-bottom: .6rem;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
.kcol {
  flex: 0 0 270px; scroll-snap-align: start;
  background: #ebedf1; border-radius: var(--radius); padding: .5rem; min-height: 220px;
}
.kcol-head { font-weight: 700; font-size: .9rem; padding: .3rem .4rem .5rem; display: flex; justify-content: space-between; }
.kcol-head .count { background: #d6d9e0; border-radius: 999px; padding: 0 .5rem; font-size: .8rem; }
.kcol-body { min-height: 160px; display: flex; flex-direction: column; gap: .5rem; }
.kcol-body.dragover { outline: 2px dashed var(--primary); outline-offset: -2px; border-radius: 8px; }
.tcard {
  display: block; background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  padding: .6rem .7rem; color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.05); cursor: grab;
}
.tcard.dragging { opacity: .5; }
.tcard.overdue { border-left: 4px solid var(--danger); }
.tcard-title { display: block; font-weight: 600; margin-bottom: .3rem; }
.tcard-meta { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .3rem; }
.tcard-foot { display: block; font-size: .8rem; color: var(--muted); }
.due-over { color: var(--danger); font-weight: 700; }

/* Ficha de tarea */
.task-badges { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .7rem; }
.task-data { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .9rem; margin: .6rem 0; }
.task-data dt { font-weight: 700; font-size: .88rem; color: var(--muted); }
.task-data dd { margin: 0; }
.comment { border-top: 1px solid var(--border); padding: .6rem 0; }
.comment-head { font-size: .86rem; color: var(--muted); margin-bottom: .2rem; }
.link-list { padding-left: 1.1rem; }
.link-list li { margin-bottom: .3rem; word-break: break-all; }
.hist { padding-left: 1.1rem; font-size: .88rem; color: var(--muted); }
.hist li { margin-bottom: .25rem; }
.photo-grid { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.photo-grid figure { margin: 0; position: relative; }
.photo-grid img { width: 130px; height: 130px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.photo-grid form { position: absolute; top: 2px; right: 2px; background: rgba(255,255,255,.85); border-radius: 6px; }

/* Filtros */
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.filters select, .filters input:not([type=checkbox]) { width: auto; margin-top: 0; max-width: 230px; }
.filters label { margin: 0; font-weight: 500; }
.filters-wrap { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem; }

/* Usuarios */
.user-row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.user-info { min-width: 200px; }

/* Calendario */
.cal-month { text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: .8rem; }
.cal-dow { text-align: center; font-weight: 700; font-size: .8rem; color: var(--muted); padding: .2rem 0; }
.cal-cell { background: var(--card); border: 1px solid var(--border); border-radius: 6px; min-height: 84px; padding: .25rem; overflow: hidden; }
.cal-empty { background: transparent; border: 0; }
.cal-today { outline: 2px solid var(--primary); }
.cal-day { font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: .2rem; }
.cal-item {
  display: block; font-size: .72rem; padding: .1rem .3rem; border-radius: 4px; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; font-weight: 600;
}
.cal-task { background: var(--primary); }
.cal-inc { background: var(--amber); }
.cal-meet { background: #6d28d9; }
.cal-closed { opacity: .45; text-decoration: line-through; }
.cal-legend { display: flex; gap: .5rem; margin-bottom: 1rem; }
.cal-legend .cal-item { display: inline-block; padding: .15rem .6rem; }
.cal-dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; margin-right: .4rem; }
.cal-list-day { margin-bottom: .7rem; }

@media (max-width: 640px) {
  .cal-cell { min-height: 52px; }
  .cal-item { font-size: 0; padding: 0; height: 6px; }
  .task-data { grid-template-columns: 1fr; }
  .task-data dt { margin-top: .4rem; }
}

/* ---------- v2 ---------- */
.pill { display: inline-block; min-width: 1.3rem; text-align: center; background: var(--danger); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 800; padding: .05rem .35rem; margin-left: .3rem; }
.resumen { font-size: 1.05rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; }
.badge-centro { background: #e0f2fe; color: #075985; }
.badge-tag { background: #fef9c3; color: #854d0e; }
.badge-ev { background: #fae8ff; color: #86198f; }
.aviso-card { border-left: 4px solid var(--amber); }
.notif-unread { border-left: 4px solid var(--primary); background: #f0f6ff; }
.vis-box { margin: .8rem 0; }
.viewers-box { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: .6rem; margin-top: .5rem; }
.viewers-box .check { margin-bottom: .4rem; }
.cal-toolbar { display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; margin-bottom: .6rem; }
.cal-toolbar input[type=date] { width: auto; margin-top: 0; }
.cal-ev { background: #86198f; }
.cal-aviso { background: var(--amber); }
.cal-agenda { display: grid; gap: .6rem; margin-bottom: 1rem; }
.cal-agenda-day { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .9rem; }
.cal-agenda-day.cal-today { outline: 2px solid var(--primary); }
.cal-agenda-head { font-weight: 700; margin-bottom: .3rem; text-transform: capitalize; }
.cal-day { display: inline-block; }
.pdf-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; width: 130px; height: 130px; border: 1px solid var(--border); border-radius: 8px; background: #fee2e2; color: #b91c1c; font-weight: 800; text-align: center; padding: .3rem; word-break: break-all; }
@media (min-width: 900px) { .cal-agenda.week7 { grid-template-columns: repeat(7, 1fr); } }

/* ---------- v3 (Tanda B) ---------- */
.badge-client { background: #dcfce7; color: #166534; }
.folder-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.folder-tile { display: flex; align-items: center; gap: .5rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; color: var(--text); font-weight: 600; }
.folder-tile:hover { border-color: var(--primary); }
.folder-ico { color: var(--amber); font-size: 1.1rem; }
.doc-row { display: block; }
.sep { border: 0; border-top: 1px solid var(--border); margin: .9rem 0; }
.check-item { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; padding: .3rem 0; border-bottom: 1px dashed var(--border); }
.check-item:last-of-type { border-bottom: 0; }
.check-done { text-decoration: line-through; color: var(--muted); }
.bar-row { display: flex; align-items: center; gap: .6rem; margin-bottom: .45rem; }
.bar-label { flex: 0 0 160px; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar { display: inline-block; height: 1rem; min-width: 2px; background: var(--primary); border-radius: 4px; flex-shrink: 1; }
.bar-warn { background: var(--amber); }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); }
.table th { font-size: .85rem; color: var(--muted); }
@media (max-width: 640px) { .bar-label { flex-basis: 110px; } }

/* ---------- v3.1 ---------- */
.status-help { margin: 0 0 .9rem; }
.status-help summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.status-help ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.status-help li { margin-bottom: .3rem; font-size: .92rem; }

/* ---------- v4 encuestas ---------- */
.poll { border-top: 1px solid var(--border); padding: .7rem 0; }
.poll:first-of-type { border-top: 0; }
.poll-form { margin: .4rem 0; }
.poll-form textarea { max-width: 480px; }
.poll-results { max-width: 480px; margin: .4rem 0; }
