:root {
  /* Paleta del logo Pymera: azul marino + naranja */
  --navy: #032e40; --navy-dark: #021f2b; --navy-2: #0a4058; --navy-light: #e4eef2;
  --brand: #fb8000; --brand-dark: #d96d00; --brand-light: #fff1e0;
  --blue: var(--navy); --blue-dark: var(--navy-dark); --blue-light: var(--navy-light);
  --text: #10242e; --muted: #5e6c84; --border: #dfe1e6;
  --bg: #f4f5f7; --card: #fff; --col: #f4f5f7; --hover: #ebecf0;
  --red: #de350b; --orange: var(--brand); --yellow: #ffab00; --green: #36b37e; --purple: #6554c0;
  /* Colores por prioridad (borde) y su tono suave (fondo) */
  --p-critica: #de350b; --p-critica-bg: #ffece7;
  --p-alta: #fb8000;    --p-alta-bg: #fff3e5;
  --p-media: #d9a400;   --p-media-bg: #fff9e0;
  --p-baja: #2a7fc0;    --p-baja-bg: #eaf3fb;
  --radius: 6px; --shadow: 0 1px 2px rgba(9,30,66,.25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--card); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }

/* ---------- Botones e inputs ---------- */
.btn { border: 0; border-radius: 4px; padding: 7px 12px; background: var(--hover); cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: #dfe1e6; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: #ffebe6; color: var(--red); }
.btn.subtle { background: transparent; }
.btn.subtle:hover { background: var(--hover); }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input { width: 100%; border: 2px solid var(--border); border-radius: 4px; padding: 6px 8px; background: #fafbfc; }
.input:focus { outline: none; border-color: var(--brand); background: #fff; }
textarea.input { resize: vertical; min-height: 70px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; min-width: 0; }

/* ---------- Entrada ---------- */
.login { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(circle at 80% 10%, rgba(251,128,0,.28), transparent 45%), linear-gradient(160deg, var(--navy-dark), var(--navy) 55%, var(--navy-2)); padding: 16px; }
.login-box { background: #fff; border-radius: 10px; padding: 32px; width: 100%; max-width: 440px; box-shadow: 0 8px 30px rgba(0,0,0,.2); text-align: center; }
.login-box h1 { margin: 8px 0 4px; font-size: 22px; }
.login-box p { color: var(--muted); margin: 0 0 24px; }
.user-pick { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px; margin-bottom: 10px; border: 2px solid var(--border); border-radius: 8px; background: #fff; cursor: pointer; text-align: left; }
.user-pick:hover { border-color: var(--brand); background: var(--brand-light); }
.user-pick small { display: block; color: var(--muted); }
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.logo img { width: 32px; height: 34px; object-fit: contain; }
.login-box .logo { flex-direction: column; gap: 10px; font-size: 20px; color: var(--navy); }
.login-box .logo img { width: 72px; height: 76px; }
.logo b { color: var(--brand); font-weight: 700; }

/* ---------- Layout ---------- */
.layout { display: flex; height: 100vh; }
.sidebar { width: 230px; flex-shrink: 0; background: var(--navy); color: #fff; padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar .logo { padding: 4px 8px 18px; color: #fff; }
.sidebar .logo img { background: #fff; border-radius: 50%; padding: 3px; }
.project-switch { display: block; margin: 0 4px 14px; }
.project-switch span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: rgba(255,255,255,.55); margin: 0 0 4px 4px; }
.project-switch select { width: 100%; background: var(--navy-2); color: #fff; border: 1px solid rgba(255,255,255,.2); border-radius: 6px; padding: 7px 8px; cursor: pointer; }
.project-switch select:focus { outline: 2px solid var(--brand); }
.project-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin: 0 4px 0 2px; vertical-align: baseline; }
.key-input { text-transform: uppercase; width: 90px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 4px; color: rgba(255,255,255,.78); text-decoration: none; font-weight: 500; }
.nav:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav.active { background: rgba(251,128,0,.16); color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar .me { margin-top: auto; display: flex; align-items: center; gap: 8px; padding: 10px 8px; border-top: 1px solid rgba(255,255,255,.14); }
.sidebar .me div { flex: 1; min-width: 0; }
.sidebar .me b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .me small { color: rgba(255,255,255,.6); }
.sidebar .btn.subtle { color: #fff; }
.sidebar .btn.subtle:hover { background: rgba(255,255,255,.12); }
.sidebar .avatar { box-shadow: 0 0 0 2px rgba(255,255,255,.5); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 16px 24px 8px; flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 22px; flex: 1; color: var(--navy); }
.crumbs { padding: 16px 24px 0; color: var(--muted); font-size: 13px; }
.content { flex: 1; overflow: auto; padding: 8px 24px 24px; }
.menu-btn { display: none; }

/* ---------- Filtros ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 0 24px 12px; }
.filters .input { width: auto; min-width: 140px; }
.filters .search { min-width: 200px; }
.avatar-filter { display: flex; }
.avatar-filter button { border: 2px solid #fff; border-radius: 50%; padding: 0; margin-left: -4px; cursor: pointer; background: none; }
.avatar-filter button.on { box-shadow: 0 0 0 2px var(--brand); position: relative; }

/* ---------- Tablero ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 12px; height: 100%; min-height: 300px; }
.column { background: var(--col); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.column-head { padding: 12px 12px 8px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; display: flex; justify-content: space-between; }
.column-body { flex: 1; padding: 4px 8px 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; min-height: 60px; border-radius: var(--radius); transition: background .15s; }
.column-body.drag-over { background: var(--brand-light); }
.card { background: var(--card); border-radius: 4px; box-shadow: var(--shadow); padding: 10px 12px; cursor: pointer; }
.card:hover { background: #fafbfc; }
.card.dragging { opacity: .4; }
.card-title { margin: 0 0 10px; word-wrap: break-word; }
.card.done .card-title { color: var(--muted); text-decoration: line-through; }
.card-meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.card-meta .key { font-weight: 600; }
.card-meta .spacer { flex: 1; }
.labels { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.label { background: var(--hover); color: var(--muted); font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 3px; text-transform: lowercase; }
.points { background: var(--hover); border-radius: 10px; padding: 0 7px; font-weight: 600; font-size: 11px; color: var(--text); }
.due { font-size: 11px; }
.due.late { color: var(--red); font-weight: 600; }

/* ---------- Iconos / badges ---------- */
.avatar { width: 26px; height: 26px; border-radius: 50%; color: #fff; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.avatar.lg { width: 36px; height: 36px; font-size: 14px; }
.avatar.empty { background: var(--border); color: var(--muted); }
.type-icon { width: 16px; height: 16px; border-radius: 3px; display: inline-grid; place-items: center; color: #fff; flex-shrink: 0; }
.type-icon svg { width: 10px; height: 10px; }
.type-Bug { background: #e5493a; }
.type-Tarea { background: #4bade8; }
.type-Mejora { background: var(--green); }
.type-Historia { background: #63ba3c; }
.prio { display: inline-flex; flex-shrink: 0; }
.prio svg { width: 16px; height: 16px; }
.status { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; white-space: nowrap; }
.status-0 { background: var(--hover); color: var(--text); }
.status-1 { background: var(--brand-light); color: #a14b00; }
.status-2 { background: #eae6ff; color: #403294; }
.status-3 { background: #e3fcef; color: #006644; }

/* ---------- Color por prioridad ---------- */
.prio-critica { --pc: var(--p-critica); --pt: var(--p-critica-bg); }
.prio-alta    { --pc: var(--p-alta);    --pt: var(--p-alta-bg); }
.prio-media   { --pc: var(--p-media);   --pt: var(--p-media-bg); }
.prio-baja    { --pc: var(--p-baja);    --pt: var(--p-baja-bg); }
.card[class*="prio-"] { border-left: 4px solid var(--pc); background: var(--pt); }
.card[class*="prio-"]:hover { filter: brightness(.98); }
.card.done { background: var(--card); }
table.list tr[class*="prio-"] td:first-child { box-shadow: inset 4px 0 0 var(--pc); }
.ticket-head { border-top: 5px solid var(--pc); border-radius: 8px 8px 0 0; background: var(--pt); }
.prio-pill { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--pc); background: #fff; border: 1px solid var(--pc); border-radius: 10px; padding: 1px 8px 1px 4px; }
.prio-legend { display: flex; gap: 12px; margin-left: auto; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.prio-legend span { display: inline-flex; align-items: center; gap: 5px; }
.prio-legend i { width: 10px; height: 10px; border-radius: 2px; background: var(--pc); }

/* ---------- Lista ---------- */
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px; border-bottom: 2px solid var(--border); cursor: pointer; user-select: none; white-space: nowrap; }
table.list th:hover { color: var(--text); }
table.list td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #fafbfc; }
.cell-flex { display: flex; align-items: center; gap: 6px; }
.empty-state { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- Modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(9,30,66,.54); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: 8px; width: 100%; max-width: 640px; box-shadow: 0 8px 30px rgba(0,0,0,.3); }
.modal.wide { max-width: 1040px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 18px; flex: 1; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.close-x { font-size: 22px; line-height: 1; padding: 4px 10px; }

/* ---------- Detalle ---------- */
.detail { display: grid; grid-template-columns: 1fr 280px; gap: 28px; }
.detail h1 { font-size: 22px; margin: 0 0 16px; word-wrap: break-word; }
.detail h4 { font-size: 13px; margin: 20px 0 6px; color: var(--text); }
.prose { white-space: pre-wrap; word-wrap: break-word; }
.prose.empty { color: var(--muted); font-style: italic; }
.bug-box { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.bug-box > div { background: var(--bg); border-radius: 4px; padding: 10px; }
.criteria { list-style: none; padding: 0; margin: 0; }
.criteria li { display: flex; gap: 8px; align-items: flex-start; padding: 4px 0; }
.criteria input { margin-top: 3px; }
.criteria li.done span { text-decoration: line-through; color: var(--muted); }
.progress { height: 6px; background: var(--hover); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.progress > div { height: 100%; background: var(--brand); }
.side-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; align-self: start; }
.side-panel .field { margin-bottom: 10px; }
.side-meta { font-size: 12px; color: var(--muted); margin-top: 12px; }
.tabs { display: flex; gap: 4px; margin: 24px 0 12px; border-bottom: 2px solid var(--border); }
.tabs button { border: 0; background: none; padding: 6px 10px; cursor: pointer; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tabs button.on { color: var(--navy); border-color: var(--brand); }
.comment { display: flex; gap: 10px; margin-bottom: 14px; }
.comment b { font-size: 13px; }
.comment small, .activity small { color: var(--muted); margin-left: 6px; }
.activity { font-size: 13px; padding: 4px 0; }

/* ---------- Crear con IA ---------- */
.ai-btn { background: var(--navy); color: #fff; }
.ai-project { width: auto; max-width: 240px; padding: 5px 8px; }
.ctx-count { font-size: 12px; color: var(--muted); }
.ctx-count.warn { color: var(--p-critica); font-weight: 600; }
.ai-btn:hover { background: var(--navy-2); }
.ai-log { height: 55vh; min-height: 280px; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; background: var(--bg); }
.ai-empty { margin: auto; text-align: center; color: var(--muted); max-width: 420px; line-height: 1.6; }
.ai-empty b { color: var(--navy); font-size: 16px; }
.ai-msg { display: flex; gap: 10px; align-items: flex-start; max-width: 85%; }
.ai-msg.user { flex-direction: row-reverse; align-self: flex-end; }
.ai-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--navy); display: grid; place-items: center; font-size: 13px; flex-shrink: 0; }
.ai-bubble { background: #fff; border-radius: 10px; padding: 10px 14px; white-space: pre-wrap; word-wrap: break-word; box-shadow: var(--shadow); min-width: 0; }
.ai-msg.user .ai-bubble { background: var(--navy); color: #fff; }
.ai-tickets { white-space: normal; display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.ai-tickets .card { cursor: default; }
.ai-desc { font-size: 13px; color: var(--text); margin-bottom: 6px; }
.ai-criteria { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.ai-done { color: #006644; font-weight: 600; }
.typing { display: flex; gap: 4px; padding: 14px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ai-input { display: flex; gap: 8px; padding: 12px 16px 4px; align-items: flex-end; border-top: 1px solid var(--border); }
.ai-input textarea { min-height: 44px; max-height: 160px; }
.mic { font-size: 18px; padding: 6px 12px; }
.mic.on { background: var(--p-critica); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(222,53,11,.5); } 100% { box-shadow: 0 0 0 10px rgba(222,53,11,0); } }
.ai-hint { padding: 0 16px 12px; font-size: 12px; color: var(--muted); }

/* ---------- Prompt / usuarios ---------- */
.prompt-box { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; white-space: pre-wrap; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; max-width: 960px; word-wrap: break-word; }
textarea.prompt-editor { min-height: 60vh; font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; }
.info { background: var(--navy-light); border-left: 4px solid var(--brand); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; max-width: 960px; }
.info ol { margin: 6px 0 0; padding-left: 20px; }
.users-table { max-width: 1100px; }
.users-table input[type=color] { width: 40px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer; }
.badge-admin { background: #eae6ff; color: #403294; font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 3px; }
.import-preview { border: 1px solid var(--border); border-radius: var(--radius); margin-top: 12px; max-height: 300px; overflow-y: auto; }
.import-preview > div { padding: 8px 12px; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.error { color: var(--red); margin-top: 8px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 6px; box-shadow: 0 4px 16px rgba(0,0,0,.25); z-index: 100; max-width: calc(100% - 32px); }
.toast.err { background: var(--red); }

/* ---------- Responsivo ---------- */
@media (max-width: 860px) {
  .menu-btn { display: inline-block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .layout.nav-open .sidebar { transform: none; box-shadow: 4px 0 20px rgba(0,0,0,.2); }
  .topbar, .filters, .content, .crumbs { padding-left: 16px; padding-right: 16px; }
  .board { grid-template-columns: repeat(4, 80vw); overflow-x: auto; }
  .detail { grid-template-columns: 1fr; }
  .bug-box, .row { grid-template-columns: 1fr; flex-direction: column; gap: 0; }
  .hide-sm { display: none; }
  .overlay { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
}
