:root {
  --bg: #f5f6f8; --panel: #fff; --ink: #1d2330; --muted: #667085; --line: #e3e6eb;
  --brand: #2f5bea; --brand-ink: #fff; --ok: #1f8a4c; --warn: #b7791f; --bad: #c0392b;
  --radius: 8px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

.topbar { background: #16213d; color: #fff; }
.topbar .inner { max-width: 1280px; margin: 0 auto; padding: .6rem 1rem; display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.topbar a { color: #d5dcf3; }
.topbar a.active, .topbar a:hover { color: #fff; text-decoration: none; }
.brand { font-weight: 700; color: #fff !important; font-size: 1.05rem; }
.nav { display: flex; gap: .9rem; flex-wrap: wrap; flex: 1; }
.nav .count { background: var(--bad); color: #fff; border-radius: 9px; padding: 0 .4rem; font-size: .75rem; }
.topbar form.search input { width: 13rem; padding: .35rem .6rem; border-radius: 6px; border: 0; }
.userbox { display: flex; gap: .6rem; align-items: center; }
.userbox button { background: none; border: 0; color: #d5dcf3; cursor: pointer; padding: 0; font: inherit; }

main { max-width: 1280px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.two { grid-template-columns: 2fr 1fr; }
.grid.halves { grid-template-columns: 1fr 1fr; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
@media (max-width: 900px) { .grid.two, .grid.halves { grid-template-columns: 1fr; } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.35rem; font-weight: 650; }

.btn, button.btn { display: inline-block; background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand); padding: .4rem .8rem; border-radius: 6px; cursor: pointer; font: inherit; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.small { padding: .2rem .5rem; font-size: .85rem; }
.linkbtn { background: none; border: 0; color: var(--brand); cursor: pointer; padding: 0; font: inherit; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; color: var(--muted); letter-spacing: .03em; font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

form.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
input[type=text], input[type=email], input[type=url], input[type=number], input[type=date], input[type=datetime-local],
input[type=password], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: .42rem .55rem; border: 1px solid #cfd4dc; border-radius: 6px; font: inherit; background: #fff;
}
form.filters input, form.filters select { width: auto; }
.field { margin-bottom: .8rem; }
.field label { display: block; font-weight: 600; margin-bottom: .2rem; }
.field .help { color: var(--muted); font-size: .85em; }
.field input[type=checkbox] { margin-right: .4rem; }
.errorlist { color: var(--bad); margin: .2rem 0; padding-left: 1rem; }
.form-narrow { max-width: 640px; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .6rem .9rem; border-radius: 6px; margin-bottom: .4rem; background: #e8f0fe; }
.messages li.success { background: #e3f5ea; }
.messages li.error { background: #fdecea; }
.messages li.warning { background: #fff5e0; }
.alert { padding: .8rem 1rem; border-radius: 6px; background: #fff5e0; border: 1px solid #f1d38b; margin-bottom: 1rem; }

.badge { display: inline-block; padding: 0 .45rem; border-radius: 9px; font-size: .75rem; font-weight: 600; background: #eef0f4; color: var(--ink); }
.badge.open { background: #e8f0fe; color: #2f5bea; }
.badge.won { background: #e3f5ea; color: var(--ok); }
.badge.lost { background: #fdecea; color: var(--bad); }
.badge.stale { background: #fff1d6; color: var(--warn); }
.badge.overdue { background: #fdecea; color: var(--bad); }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: .8rem; overflow-x: auto; padding-bottom: .5rem; }
.column { background: #eceff4; border-radius: var(--radius); padding: .7rem; min-height: 200px; }
.column header { margin-bottom: .6rem; }
.column header .totals { font-size: .82rem; color: var(--muted); }
.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: .6rem; margin-bottom: .5rem; }
.card .title { font-weight: 600; }
.card form { display: flex; gap: .3rem; margin-top: .4rem; }
.card form select { padding: .2rem; font-size: .85rem; }

.bar { background: #e8ecf5; border-radius: 4px; height: 18px; position: relative; overflow: hidden; }
.bar span { position: absolute; left: 0; top: 0; bottom: 0; background: #b9c8f7; }
.bar span.weighted { background: var(--brand); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.kind { font-size: .72rem; text-transform: uppercase; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }
details summary { cursor: pointer; font-weight: 600; margin-bottom: .5rem; }
.pagination { display: flex; gap: .6rem; align-items: center; margin-top: .8rem; }
.inline-form { display: inline; }
.task-done { text-decoration: line-through; color: var(--muted); }

.login-box { max-width: 380px; margin: 4rem auto; }
