:root {
  --bg: #f4f3f1;
  --surface: #ffffff;
  --surface-2: #ebe9e5;
  --border: #dcd9d3;
  --border-input: #8f8a82;
  --text: #1f1d24;
  --muted: #5f5b55;
  --accent: #c2410c;
  --accent-hover: #9a3412;
  --on-accent: #ffffff;
  --danger: #b91c1c;
  --success: #15803d;
  --focus: #2563eb;
  --top: #1f1d24;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(0,0,0,.08), 0 2px 8px rgba(0,0,0,.06);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 18px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.hidden { display: none !important; }

button, .btn {
  font: inherit; cursor: pointer; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 6px 12px; line-height: 20px; display: inline-flex; align-items: center; gap: 6px;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
button.primary:hover { background: var(--accent-hover); }
button.danger { color: var(--danger); border-color: #e7b4b4; }
button.ghost { border-color: transparent; background: transparent; }
button.ghost:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: default; }
button.icon { padding: 4px 8px; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-input);
  border-radius: var(--radius); padding: 6px 8px; width: 100%;
}
textarea { resize: vertical; min-height: 70px; }
input[type=checkbox] { width: auto; }
label.field { display: block; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }

/* barra superior */
.top { height: 50px; background: var(--top); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 16px; position: sticky; top: 0; z-index: 20; }
.top a { color: #f2efe9; }
.top .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: #fff; }
.top .brand img { width: 24px; height: 24px; }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 6px 10px; border-radius: var(--radius); }
.top nav a:hover, .top nav a.on { background: #3a3741; text-decoration: none; }
.top input.search { width: 260px; background: #2e2b34; border-color: #4a4652; color: #fff; }
.top input.search::placeholder { color: #b9b4ad; }
.top .user { position: relative; }
.top .user > button { background: transparent; border-color: transparent; color: #fff; }
.top .user > button:hover { background: #3a3741; }
.menu { position: absolute; right: 0; top: 40px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 180px; padding: 4px; z-index: 30; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; background: none; color: var(--text); border-radius: 4px; }
.menu a:hover, .menu button:hover { background: var(--surface-2); text-decoration: none; }

main { padding: 20px 24px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 600; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.project-card { display: block; color: var(--text); }
.project-card:hover { border-color: var(--accent); text-decoration: none; }
.project-card .key { font-weight: 700; color: var(--accent); font-size: 12px; letter-spacing: .05em; }
.project-card .name { font-size: 16px; font-weight: 600; margin: 2px 0 6px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }

/* login */
.auth { max-width: 360px; margin: 10vh auto; }
.auth .brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; font-size: 24px; font-weight: 700; }
.auth .brand img { width: 40px; height: 40px; }
.error { color: var(--danger); min-height: 20px; }

/* pizarra */
.sprint-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.filters input { width: 220px; }
.chip { border-radius: 999px; padding: 2px 10px 2px 2px; font-size: 13px; }
.chip.on { border-color: var(--accent); background: #fbe8df; }
.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; }
.col { background: var(--surface-2); border-radius: 8px; width: 290px; min-width: 260px; flex: 0 0 290px; display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.col-head { padding: 10px 12px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); display: flex; justify-content: space-between; }
.col-head .done { color: var(--success); }
.col-body { padding: 0 8px 8px; overflow-y: auto; min-height: 60px; flex: 1; }
.tcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 9px 10px; margin-bottom: 8px; cursor: pointer; box-shadow: 0 1px 1px rgba(0,0,0,.04); }
.tcard:hover { border-color: var(--border-input); }
.tcard .title { margin-bottom: 8px; word-break: break-word; }
.tcard .meta { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.tcard.dragging, .trow.dragging { opacity: .4; }
.placeholder { border: 2px dashed var(--accent); border-radius: var(--radius); height: 38px; margin-bottom: 8px; background: #fbe8df; }
.quick-add { margin-top: 2px; }
.quick-add input { background: var(--surface); }

/* backlog */
.bsection { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 14px; }
.bsection-head { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.bsection-head .goal { flex-basis: 100%; }
.bsection-body { min-height: 40px; padding: 4px 0; }
.trow { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid #f0eeea; cursor: pointer; background: var(--surface); }
.trow:hover { background: #faf9f7; }
.trow .key { font-size: 12px; color: var(--muted); width: 74px; flex: none; }
.trow .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .placeholder { margin: 0; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; background: var(--surface-2); color: #45413b; white-space: nowrap; }
.pill.done { background: #dcfce7; color: #14532d; }
.pill.active { background: #dbeafe; color: #1e3a8a; }
.points { background: var(--surface-2); border-radius: 999px; padding: 0 7px; font-size: 12px; min-width: 22px; text-align: center; color: #3b3833; }

/* iconos */
.type { width: 16px; height: 16px; border-radius: 3px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 10px; font-weight: 800; flex: none; }
.type.task { background: #2563eb; }
.type.bug { background: #dc2626; }
.type.story { background: #16a34a; }
.type.epic { background: #7c3aed; }
.prio { font-weight: 800; font-size: 12px; flex: none; }
.prio.highest { color: #b91c1c; } .prio.high { color: #ea580c; } .prio.medium { color: #a16207; } .prio.low { color: #2563eb; } .prio.lowest { color: #64748b; }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; }
.avatar.none { background: #cfccc6; color: #57534e; }
.label { background: #ede9fe; color: #4c1d95; border-radius: 4px; padding: 0 6px; font-size: 11px; }
.overdue { color: var(--danger); font-weight: 600; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(20,18,24,.45); z-index: 40; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 10px; width: 100%; max-width: 520px; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal.wide { max-width: 1100px; padding: 0; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

/* tarea */
.task-layout { display: grid; grid-template-columns: 1fr 300px; min-height: 60vh; }
.task-main { padding: 18px 22px 30px; min-width: 0; }
.task-side { padding: 18px; background: #faf9f7; border-left: 1px solid var(--border); border-radius: 0 10px 10px 0; }
.task-side label.field { margin-bottom: 12px; }
.task-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.task-title { font-size: 22px; font-weight: 600; width: 100%; border: 1px solid transparent; padding: 4px 6px; margin-left: -6px; }
.task-title:hover:not(:disabled) { border-color: var(--border); }
.desc { white-space: pre-wrap; word-break: break-word; padding: 8px; margin-left: -8px; border-radius: var(--radius); cursor: text; min-height: 40px; }
.desc:hover { background: #faf9f7; }
.desc.placeholder-text { color: var(--muted); }
.files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.file { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; font-size: 12px; background: var(--surface); }
.file .thumb { height: 90px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--muted); font-weight: 700; font-size: 18px; overflow: hidden; }
.file .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file .info { padding: 6px 8px; display: flex; gap: 4px; align-items: center; }
.file .info a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.drop { border: 2px dashed var(--border); border-radius: 8px; padding: 14px; text-align: center; color: var(--muted); margin-top: 10px; }
.drop.over { border-color: var(--accent); background: #fbe8df; }
.links .link { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 6px; }
.links .link .rel { font-size: 12px; color: var(--muted); width: 110px; flex: none; }
.links .link a.t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.strike { text-decoration: line-through; }
.comment { display: flex; gap: 10px; margin-bottom: 14px; }
.comment .body { white-space: pre-wrap; word-break: break-word; margin-top: 2px; }
.comment .head { font-size: 13px; }
.activity li { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.activity { padding-left: 18px; }

table.list { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
table.list th, table.list td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #efede9; }
table.list th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; background: #faf9f7; }
table.list tr.off td { color: var(--muted); }

.cols-edit .crow { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.cols-edit .crow input[type=text] { max-width: 260px; }
.members { columns: 2; max-width: 560px; }
.members label { display: flex; gap: 8px; align-items: center; padding: 3px 0; break-inside: avoid; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1f1d24; color: #fff; padding: 10px 16px; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 60; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { background: var(--danger); }

@media (max-width: 860px) {
  .task-layout { grid-template-columns: 1fr; }
  .task-side { border-left: 0; border-top: 1px solid var(--border); border-radius: 0 0 10px 10px; }
  .top input.search { width: 140px; }
  main { padding: 14px; }
  .overlay { padding: 0; }
  .modal.wide { border-radius: 0; min-height: 100vh; }
}
