:root {
  --bg: #f4f6f8; --panel: #ffffff; --ink: #1a2733; --muted: #667685; --line: #e3e8ee;
  --brand: #0f4c81; --brand-ink: #ffffff; --accent: #1f8a70; --warn: #b4690e; --danger: #b4232c;
  --prio: #1f8a70; --chip: #eef2f6; --radius: 10px; --shadow: 0 1px 3px rgba(16,32,48,.08), 0 1px 2px rgba(16,32,48,.06);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--brand); }
h1,h2,h3,h4 { margin: 0 0 .4em; line-height: 1.25; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; width: 100%; padding: .55rem .65rem; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 72px; resize: vertical; }
label { display: block; font-size: .82rem; color: var(--muted); margin: .5rem 0 .2rem; font-weight: 600; }
.hidden, [hidden] { display: none !important; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: #fff;
  color: var(--ink); padding: .5rem .85rem; border-radius: 8px; font-weight: 600; }
.btn:hover { border-color: #c7d0da; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { background: #0c3e6a; }
.btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); padding: .4rem .5rem; }
.btn.danger { color: var(--danger); border-color: #e6c3c5; }
.btn.sm { padding: .3rem .55rem; font-size: .84rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: #0c2740; color: #cdd8e4; padding: 1rem .8rem; display: flex; flex-direction: column; }
.sidebar .brand { color: #fff; font-weight: 800; font-size: 1.05rem; display: flex; gap: .5rem; align-items: center; padding: .3rem .5rem 1rem; }
.nav a { display: flex; align-items: center; gap: .6rem; color: #cdd8e4; text-decoration: none; padding: .6rem .7rem;
  border-radius: 8px; font-weight: 600; margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav .badge { margin-left: auto; background: var(--warn); color: #fff; border-radius: 20px; padding: 0 .4rem; font-size: .72rem; }
.sidebar .spacer { flex: 1; }
.sidebar .userbox { border-top: 1px solid rgba(255,255,255,.12); padding-top: .7rem; font-size: .85rem; }
.main { padding: 1.3rem 1.6rem 3rem; overflow-x: hidden; max-width: 1200px; }
.topbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.topbar .grow { flex: 1; }

/* Cards / panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } .layout { grid-template-columns: 1fr; } .sidebar { flex-direction: row; flex-wrap: wrap; } .sidebar .spacer { display: none; } }

.stat { text-align: center; } .stat .num { font-size: 1.8rem; font-weight: 800; color: var(--brand); } .stat .lbl { color: var(--muted); font-size: .82rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: .6rem; }
.divider { height: 1px; background: var(--line); margin: .8rem 0; }

/* Chips / badges */
.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--chip); color: var(--ink);
  border-radius: 20px; padding: .15rem .6rem; font-size: .78rem; font-weight: 600; }
.chip.prio { background: #e2f3ee; color: var(--prio); }
.chip.fact { background: #e2f0fb; color: #14538a; }
.chip.slutsats { background: #fdf1dc; color: #8a5a0e; }
.chip.hypotes { background: #f3e6f0; color: #7a2f66; }
.chip.strong { background: #e2f3ee; color: var(--prio); } .chip.medel { background: #fdf1dc; color:#8a5a0e;} .chip.svag { background:#f0f0f0; color:#666;}
.tag { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }

/* Score bar */
.scorebar { background: #eef2f6; border-radius: 6px; height: 8px; overflow: hidden; }
.scorebar > i { display: block; height: 100%; background: var(--brand); }
.scoretotal { font-size: 1.6rem; font-weight: 800; }
.scoretotal.prio { color: var(--prio); }

/* Lists */
.list-item { display: flex; align-items: center; gap: .8rem; padding: .7rem .2rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #f7f9fb; }
.list-item .title { font-weight: 700; } .list-item .sub { color: var(--muted); font-size: .85rem; }

/* Pipeline board */
.board { display: flex; gap: .8rem; overflow-x: auto; padding-bottom: .8rem; }
.col { min-width: 240px; width: 240px; flex: 0 0 auto; background: #eef2f6; border-radius: 10px; padding: .5rem; }
.col h4 { font-size: .82rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); display: flex; justify-content: space-between; }
.oppcard { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .6rem; margin-bottom: .5rem; cursor: pointer; box-shadow: var(--shadow); }
.oppcard:hover { border-color: var(--brand); }
.oppcard .c { font-weight: 700; font-size: .92rem; } .oppcard .r { color: var(--muted); font-size: .82rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg,#0c2740,#0f4c81); }
.login-card { background: #fff; padding: 2rem; border-radius: 14px; width: 360px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-card h1 { text-align: center; }

/* Toast + modal */
.toast { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); background: #1a2733; color: #fff;
  padding: .7rem 1.1rem; border-radius: 8px; box-shadow: var(--shadow); z-index: 50; max-width: 90%; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--accent); }
.modal-backdrop { position: fixed; inset: 0; background: rgba(12,25,40,.5); display: grid; place-items: center; z-index: 40; padding: 1rem; }
.modal { background: #fff; border-radius: 12px; width: min(720px, 100%); max-height: 88vh; overflow: auto; padding: 1.3rem 1.4rem; box-shadow: 0 20px 60px rgba(0,0,0,.35); }

/* Spinner */
.spinner { width: 18px; height: 18px; border: 3px solid #cbd5e0; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 3rem; color: var(--muted); gap: .6rem; }

pre.mail { background: #f7f9fb; border: 1px solid var(--line); border-radius: 8px; padding: .8rem; white-space: pre-wrap; font: inherit; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: .3rem .8rem; }
.kv dt { color: var(--muted); font-weight: 600; } .kv dd { margin: 0; }
.notice { background: #fdf6e7; border: 1px solid #f0dca8; color: #7a5a12; padding: .6rem .8rem; border-radius: 8px; font-size: .88rem; }
.ai-note { background: #eef4fa; border: 1px solid #cfe0f0; color: #124e82; padding: .5rem .7rem; border-radius: 8px; font-size: .82rem; }
