:root {
  --bg: #f6f7f9;
  --surface: #fff;
  --surface-2: #f1f3f6;
  --border: #dfe3e8;
  --text: #1d2530;
  --muted: #5d6b7c;
  --primary: #2563eb;
  --primary-600: #1d4ed8;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 8px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 10%);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.boot { padding: 2rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: .75rem; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.25rem;
  height: 52px; padding: 0 1.25rem;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 16px; color: var(--text); }
.brand::before { content: ""; width: 22px; height: 22px; border-radius: 6px; background: url(/favicon.svg) center/cover; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: .25rem; }
.nav a { padding: .4rem .7rem; border-radius: 6px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { color: var(--primary); background: #eff4ff; }
.main { max-width: 1400px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; }
.page-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tabs a { padding: .5rem .8rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Componentes ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  height: 34px; padding: 0 .9rem; border-radius: 6px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); }
.btn.danger { color: var(--danger); border-color: #f5c2c2; }
.btn.danger:hover { background: #fef2f2; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 28px; padding: 0 .6rem; font-size: 13px; }

label.field { display: block; }
label.field > span { display: block; font-weight: 600; font-size: 12px; color: var(--muted); margin-bottom: .25rem; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid var(--border); border-radius: 6px; padding: .45rem .6rem;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid #93b4fb; outline-offset: 0; border-color: var(--primary); }
textarea { resize: vertical; min-height: 90px; }
.inline-input { border-color: transparent; background: transparent; font-size: 1.4rem; font-weight: 700; padding: .2rem .4rem; }
.inline-input:hover { background: var(--surface-2); }
.row > .inline-input { flex: 1; width: auto; min-width: 0; }
.issue-title { flex-wrap: nowrap; margin: .25rem 0 1rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.filters > * { width: auto; min-width: 140px; }
.filters input[type=search] { min-width: 220px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 1em; }

table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { text-align: left; padding: .55rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; background: var(--surface-2); }
tbody tr:hover { background: #fafbfc; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
.empty { padding: 2rem; text-align: center; color: var(--muted); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: 0 .5rem; height: 22px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.status-todo { background: #e9edf2; color: #42526e; }
.status-in_progress { background: #dbeafe; color: #1e40af; }
.status-in_review { background: #fef3c7; color: #92400e; }
.status-done { background: #dcfce7; color: #166534; }
.type { width: 18px; height: 18px; padding: 0; justify-content: center; color: #fff; font-size: 11px; border-radius: 4px; }
.type-task { background: #3b82f6; }
.type-bug { background: #ef4444; }
.type-story { background: #22c55e; }
.type-epic { background: #8b5cf6; }
.prio { font-size: 12px; font-weight: 600; }
.prio::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .3rem; background: currentColor; }
.prio-highest { color: #b91c1c; } .prio-high { color: #ea580c; } .prio-medium { color: #ca8a04; }
.prio-low { color: #16a34a; } .prio-lowest { color: #64748b; }
.key { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; color: var(--muted); }
.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 24px; height: 24px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700;
}
.avatar.lg { width: 32px; height: 32px; font-size: 13px; }
.avatar.none { background: #cbd5e1; }

/* ---------- Tablero ---------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: .75rem; overflow-x: auto; align-items: start; }
.column { background: var(--surface-2); border-radius: var(--radius); padding: .5rem; min-height: 240px; }
.column-head { display: flex; justify-content: space-between; padding: .25rem .35rem .5rem; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.column.drop { outline: 2px dashed var(--primary); outline-offset: -2px; background: #eef3ff; }
.cards { display: flex; flex-direction: column; gap: .5rem; min-height: 60px; }
.issue-card {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
  padding: .6rem .7rem; box-shadow: var(--shadow); cursor: grab; color: var(--text);
}
.issue-card:hover { border-color: #b6c2d2; text-decoration: none; }
.issue-card.dragging { opacity: .4; }
.issue-card .title { margin-bottom: .5rem; overflow-wrap: anywhere; }
.issue-card .meta { display: flex; align-items: center; gap: .4rem; }
.drop-marker { height: 3px; border-radius: 2px; background: var(--primary); }

/* ---------- Detalle ---------- */
.issue-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.5rem; }
.issue-side .field { margin-bottom: .75rem; }
.description { white-space: pre-wrap; overflow-wrap: anywhere; min-height: 2rem; }
.comment { display: flex; gap: .6rem; padding: .75rem 0; border-top: 1px solid var(--border); }
.comment-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.activity { list-style: none; padding: 0; margin: 0; }
.activity li { padding: .4rem 0; border-top: 1px solid var(--border); font-size: 13px; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth .card { width: 100%; max-width: 380px; padding: 1.75rem; }
.auth h1 { text-align: center; }

/* ---------- Diálogos y avisos ---------- */
dialog { border: none; border-radius: 10px; padding: 0; width: min(560px, 94vw); box-shadow: 0 20px 50px rgb(0 0 0 / 25%); }
dialog::backdrop { background: rgb(15 23 42 / 45%); }
.dialog-body { padding: 1.25rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; padding: .9rem 1.25rem; border-top: 1px solid var(--border); background: var(--surface-2); }
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { padding: .6rem .9rem; border-radius: 6px; background: #1e293b; color: #fff; box-shadow: var(--shadow); max-width: 360px; }
.toast.error { background: var(--danger); }

@media (max-width: 900px) {
  .issue-layout { grid-template-columns: 1fr; }
  .nav a { padding: .4rem .45rem; }
}
