:root {
  --blue: #0057a8;
  --deep: #003a70;
  --ink: #18324a;
  --muted: #61788f;
  --line: #d7e3ef;
  --bg: #f4f7fb;
  --ok: #1f7a4d;
  --bug: #b42318;
  --warn: #b36b00;
  --proc: #0b6e99;
  --sidebar: #0b2a4a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
.muted { color: var(--muted); font-size: .9rem; }
.error { background: #fff4f0; border-left: 4px solid var(--bug); padding: .75rem 1rem; color: #7a1a12; }
.ok { background: #eefaf3; border-left: 4px solid var(--ok); padding: .75rem 1rem; color: #145a38; }

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: linear-gradient(180deg, var(--sidebar), #061a30);
  color: #e8f1fa;
  display: flex;
  flex-direction: column;
  padding: 1.1rem .85rem;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: .4rem .55rem 1.1rem;
  border-bottom: 1px solid rgba(255,255,255,.12);
  margin-bottom: .85rem;
}
.sidebar-brand strong { display: block; font-size: 1.05rem; letter-spacing: .02em; }
.sidebar-brand span { font-size: .75rem; opacity: .7; }
.sidebar-nav { display: grid; gap: .35rem; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .55rem;
  color: #d7e6f5 !important; padding: .65rem .7rem; border-radius: 8px;
  font-weight: 600; font-size: .92rem;
}
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.is-active { background: rgba(0,87,168,.55); color: #fff !important; }
.nav-ico { width: 1.2rem; text-align: center; opacity: .9; }
.sidebar-foot {
  border-top: 1px solid rgba(255,255,255,.12);
  padding-top: .85rem; display: grid; gap: .45rem;
}
.sidebar-foot a { color: #9ec4e8 !important; font-size: .85rem; }
.app-main { min-width: 0; display: flex; flex-direction: column; }
.topbar-slim {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: .85rem 1.25rem; display: flex; justify-content: space-between; align-items: center;
}
.page-title { margin: 0; font-size: 1.15rem; color: var(--deep); }
.detail-badge { padding: .75rem 1.25rem 0; display: flex; gap: .55rem; align-items: center; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: .85rem 1.25rem; gap: 1rem; flex-wrap: wrap;
}
.topbar nav { display: flex; gap: .85rem; align-items: center; }
.btn {
  display: inline-block; background: var(--blue); color: #fff !important;
  padding: .45rem .9rem; border-radius: 6px; font-weight: 600; font-size: .9rem;
}
.user { font-size: .9rem; color: var(--muted); }

.filters {
  display: flex; gap: .5rem; flex-wrap: wrap; padding: 1rem 1.25rem;
}
.filters input, .filters select, .filters button,
label input, label select, label textarea, button {
  font: inherit; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 6px;
}
button, .filters button {
  background: var(--deep); color: #fff; border: none; cursor: pointer; font-weight: 600;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: .75rem;
  padding: 0 1.25rem 1.5rem;
  overflow-x: auto;
  align-items: start;
}
.col {
  background: #eef3f8; border-radius: 10px; padding: .65rem; min-height: 420px;
}
.col header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem;
}
.col h2 { margin: 0; font-size: .95rem; }
.pill {
  display: inline-block; border-radius: 999px; padding: .1rem .55rem;
  font-size: .75rem; font-weight: 700; color: #fff; background: #64748b;
}
.pill-abierta { background: #64748b; }
.pill-en_proceso { background: var(--proc); }
.pill-con_bugs { background: var(--bug); }
.pill-revision_funcional { background: var(--warn); }
.pill-cerrada { background: var(--ok); }

.card {
  display: block; background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: .65rem; margin-bottom: .55rem; color: inherit;
  box-shadow: 0 1px 2px rgba(0,40,80,.06);
}
.card:hover { border-color: var(--blue); }
.card-top { display: flex; justify-content: space-between; gap: .35rem; }
.card .id { color: var(--blue); font-weight: 700; font-size: .85rem; }
.card .title { font-weight: 600; margin: .35rem 0; font-size: .9rem; line-height: 1.3; }
.card .meta { color: var(--muted); font-size: .75rem; margin-top: .2rem; }

.prio {
  font-size: .68rem; font-weight: 700; padding: .1rem .4rem; border-radius: 3px;
  background: #fff3cd; color: #7a5b00;
}
.prio-muy_alta { background: #ffd0c8; color: #7a0f0f; }
.prio-alta { background: #ffe8e0; color: #9b1c1c; }
.prio-media { background: #fff3cd; color: #7a5b00; }
.prio-baja { background: #e8f1fa; color: var(--deep); }

.auth-page {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(160deg, #e8f1fa, #f7fafc 55%, #fff8e6);
}
.auth-card {
  width: min(380px, 92vw); background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 1.5rem; box-shadow: 0 8px 30px rgba(0,40,80,.08);
}
.auth-card h1 { margin: .2rem 0 .4rem; color: var(--deep); font-size: 1.4rem; }
.kicker { color: var(--blue); font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin: 0; }
.auth-card form { display: grid; gap: .75rem; margin-top: 1rem; }
.auth-card label { display: grid; gap: .3rem; font-size: .85rem; color: var(--muted); }

.form-page, .detail-grid, .metrics-page { padding: 1rem 1.25rem 2rem; }
.form-grid { display: grid; gap: 1rem; max-width: 960px; }
.form-grid fieldset {
  border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 1rem;
  display: grid; grid-template-columns: 1fr 1fr; gap: .75rem;
}
.form-grid legend { font-weight: 700; color: var(--deep); padding: 0 .35rem; }
.form-grid label, .stack label { display: grid; gap: .3rem; font-size: .85rem; color: var(--muted); }
.form-grid .full { grid-column: 1 / -1; }
.actions { max-width: 960px; }

.detail-grid {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 1rem; align-items: start;
}
.detail-grid .full { grid-column: 1 / -1; }
.panel {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1rem;
}
.panel h2 { margin: 0 0 .75rem; font-size: 1.05rem; color: var(--deep); }
.stack { display: grid; gap: .65rem; }
.timeline { margin: 0; padding-left: 1.1rem; }
.timeline li { margin-bottom: .85rem; }

.metrics-summary {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem;
}
.metric-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 1rem; text-align: center;
}
.metric-card .n { font-size: 1.75rem; font-weight: 700; color: var(--deep); }
.metric-card .l { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.col-metrics {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: .75rem;
}
.col-metric {
  border: 1px solid var(--line); border-radius: 8px; padding: .75rem; background: #f8fbfe;
}
.col-metric header { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.col-count { font-size: 1.25rem; color: var(--deep); }
.bar-track { height: 8px; background: #e2ebf4; border-radius: 99px; overflow: hidden; margin-bottom: .45rem; }
.bar-fill { height: 100%; border-radius: 99px; background: #64748b; }
.bar-abierta { background: #64748b; }
.bar-en_proceso { background: var(--proc); }
.bar-con_bugs { background: var(--bug); }
.bar-revision_funcional { background: var(--warn); }
.bar-cerrada { background: var(--ok); }
.metrics-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem;
}
.metrics-grid-wide { grid-column: 1 / -1; }
.metrics-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.metrics-table th, .metrics-table td {
  border-bottom: 1px solid var(--line); padding: .45rem .35rem; text-align: left;
}
.metrics-table th { color: var(--deep); font-size: .8rem; }

@media (max-width: 1100px) {
  .col-metrics { grid-template-columns: 1fr 1fr; }
  .metrics-summary { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; }
  .board { grid-template-columns: repeat(5, 240px); }
  .detail-grid, .form-grid fieldset, .metrics-grid { grid-template-columns: 1fr; }
  .col-metrics { grid-template-columns: 1fr; }
}
