:root {
  --navy: #0f2a44; --navy2: #17395c; --gold: #c8a24a; --bg: #f4f6f9; --card: #fff;
  --text: #1c2733; --muted: #6b7785; --line: #e3e8ee; --good: #1f8a5b; --warn: #b7791f; --bad: #c0392b;
  --radius: 12px; --shadow: 0 1px 2px rgba(15,42,68,.06), 0 2px 8px rgba(15,42,68,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); -webkit-text-size-adjust: 100%; }
a { color: var(--navy2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2rem 0 .6rem; }
h2.section { font-size: 1rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 1rem 0 .5rem; }
h3 { font-size: 1.02rem; margin: 0 0 .7rem; }
code, .mono { font-family: ui-monospace, Menlo, monospace; font-size: .86em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: var(--navy); color: #dbe5ef; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0; }
.brand { display: flex; gap: .7rem; align-items: center; padding: 1.1rem 1rem; }
.brand.center { justify-content: center; margin-bottom: 1rem; }
.brand strong { display: block; color: #fff; }
.login-card .brand strong { color: var(--navy); }
.brand small { color: #9fb3c8; font-size: .78rem; }
.logo { width: 38px; height: 38px; border-radius: 10px; background: var(--gold); color: var(--navy); display: grid; place-items: center; font-weight: 800; }
.sidebar nav { display: flex; flex-direction: column; padding: .3rem .5rem; flex: 1; }
.sidebar nav a { color: #dbe5ef; padding: .55rem .7rem; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; }
.sidebar nav a:hover { background: var(--navy2); text-decoration: none; }
.sidebar nav a.active { background: var(--gold); color: var(--navy); font-weight: 600; }
.sidebar nav a.later { color: #8098b0; }
.sidebar nav a em { font-style: normal; font-size: .7rem; border: 1px solid #44617e; border-radius: 6px; padding: 0 .35rem; }
.logout { padding: .9rem 1rem; border-top: 1px solid #23476b; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.logout .who { font-size: .8rem; color: #9fb3c8; }
.main { flex: 1; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5; background: rgba(244,246,249,.95); backdrop-filter: blur(6px); display: flex; gap: .6rem; align-items: center; padding: .7rem 1.2rem; border-bottom: 1px solid var(--line); }
.menu-btn { display: none; font-size: 1.3rem; background: none; border: 0; padding: .3rem .5rem; cursor: pointer; color: var(--navy); }
.search { flex: 1; }
.search input { width: 100%; max-width: 560px; }
.content { padding: 1.2rem; max-width: 1200px; }
.scrim { display: none; }

/* Cards / grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); margin-bottom: 1rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid2 > .card, .grid3 > .card { margin-bottom: 0; }
.grid2, .grid3 { margin-bottom: 1rem; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-start; gap: .8rem; flex-wrap: wrap; margin-bottom: .6rem; }
.pagehead h1, .pagehead h3 { margin-bottom: .3rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; display: flex; flex-direction: column; box-shadow: var(--shadow); color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--gold); }
.stat b { font-size: 1.6rem; color: var(--navy); }
.stat span { font-size: .82rem; color: var(--muted); }
.stat.good b { color: var(--good); } .stat.warn b { color: var(--warn); } .stat.muted-stat b { color: var(--muted); }

/* Lists */
.list { list-style: none; margin: 0; padding: 0; }
.list li { border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.list li > a, .list li > div { display: flex; flex-direction: column; padding: .55rem 0; color: var(--text); }
.list li span { font-size: .84rem; }
.rows { display: flex; flex-direction: column; gap: .5rem; }
.row { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem; display: flex; align-items: center; gap: .5rem; color: var(--text); flex-wrap: wrap; }
a.row:hover { text-decoration: none; border-color: var(--gold); }
.card .row { box-shadow: none; }
.row-main { flex: 1; min-width: 180px; display: flex; flex-direction: column; color: var(--text); }
.row-main span { font-size: .84rem; }
.pipeline { list-style: none; padding: 0; margin: 0; }
.pipeline a { display: grid; grid-template-columns: 140px 1fr 36px; gap: .6rem; align-items: center; padding: .3rem 0; color: var(--text); }
.pipeline b { text-align: right; }
progress { width: 100%; height: 10px; appearance: none; border: 0; border-radius: 6px; background: #edf1f5; overflow: hidden; }
progress::-webkit-progress-bar { background: #edf1f5; border-radius: 6px; }
progress::-webkit-progress-value { background: var(--gold); border-radius: 6px; }
progress::-moz-progress-bar { background: var(--gold); border-radius: 6px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid var(--line); padding: .3rem 0 .6rem .8rem; }
.changes { display: flex; flex-wrap: wrap; gap: .3rem .9rem; font-size: .82rem; color: var(--muted); }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: .35rem .8rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .88rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.notes { white-space: pre-wrap; background: #fbf8ef; border-radius: 8px; padding: .6rem .8rem; }
table.mini { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.mini th, table.mini td { text-align: left; padding: .4rem .3rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.report tr.r-created td, .report tr.r-new td { background: #eef8f2; }
.report tr.r-error td, .report tr.r-skipped td { background: #fdf0ee; }

/* Tags */
.pill, .tag, .status { display: inline-block; font-size: .76rem; padding: .12rem .55rem; border-radius: 999px; background: #edf1f5; color: var(--navy2); white-space: nowrap; font-weight: 600; }
.tag.good, .pill.good { background: #e3f4ec; color: var(--good); }
.tag.bad { background: #fbe7e4; color: var(--bad); }
.pill.warn { background: #fdf1dd; color: var(--warn); }
.status.s-registered, .status.s-active { background: #e3f4ec; color: var(--good); }
.status.s-interested, .status.s-form-sent, .status.s-documents-pending, .status.s-submitted { background: #fdf1dd; color: var(--warn); }

/* Forms */
input, select, textarea { font: inherit; width: 100%; padding: .55rem .7rem; border: 1px solid #cfd8e2; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem 1rem; }
.form label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; font-weight: 600; }
.form label small { font-weight: 400; }
.form .wide, .form .actions { grid-column: 1 / -1; }
.form label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
.form label.check input { width: auto; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.filters input { flex: 2; min-width: 160px; } .filters select { flex: 1; min-width: 140px; width: auto; }
.inline { display: inline; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 40px; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn.primary { background: var(--navy); color: #fff; }
.btn.ghost { background: #fff; border-color: #cfd8e2; color: var(--navy); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.small { padding: .3rem .7rem; min-height: 32px; font-size: .85rem; }
.btn.full { width: 100%; }
.flash { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; background: #edf1f5; }
.flash.ok { background: #e3f4ec; color: #145c3c; }
.flash.err { background: #fbe7e4; color: #8e2a1f; }
.flash a { font-weight: 600; margin-left: .4rem; }
details.danger summary { cursor: pointer; color: var(--bad); font-weight: 600; }
.pager { display: flex; gap: .8rem; align-items: center; justify-content: center; margin: 1rem 0; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg, var(--navy), #24507d); padding: 1rem; }
.login-card { background: #fff; padding: 1.6rem; border-radius: 16px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: .9rem; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-card label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; }

/* Mobile */
@media (max-width: 900px) {
  .grid3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 4px 0 20px rgba(0,0,0,.2); }
  body.menu-open .sidebar { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 15; }
  .menu-btn { display: block; }
  .topbar { padding: .6rem .8rem; }
  .content { padding: .9rem .8rem; }
  .grid2 { grid-template-columns: 1fr; }
  .form { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .dl { grid-template-columns: 110px 1fr; }
  .pipeline a { grid-template-columns: 120px 1fr 30px; }
  h1 { font-size: 1.3rem; }
  table.mini { display: block; overflow-x: auto; }
}
