:root{
  --bg:#f4f6f9;
  --surface:#ffffff;
  --border:#e4e8ef;
  --text:#1a2233;
  --text-muted:#6b7688;
  --accent:#1d4ed8;
  --accent-dark:#173fb0;
  --accent-soft:#e8eefd;
  --ok:#0f9d58;
  --ok-soft:#e5f7ee;
  --warn:#b7791f;
  --warn-soft:#fdf3da;
  --danger:#dc2626;
  --danger-soft:#fdecec;
  --radius:14px;
  --shadow:0 1px 2px rgba(16,24,40,.04), 0 4px 16px rgba(16,24,40,.06);
}
*{box-sizing:border-box;}
body{
  margin:0;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
  background:
    radial-gradient(1100px 420px at 12% -10%, #eef3ff 0%, rgba(238,243,255,0) 60%),
    var(--bg);
  color:var(--text);
  -webkit-font-smoothing:antialiased;
}

header.topbar{
  background:linear-gradient(135deg,#0f1b3d,#16234f 55%,#1d4ed8);
  color:#fff;
  padding:18px clamp(16px,4vw,48px);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
}
header.topbar .brand{
  display:flex;
  align-items:center;
  gap:10px;
  text-decoration:none;
  color:#fff;
}
header.topbar .brand-mark{
  width:32px;height:32px;
  border-radius:9px;
  background:rgba(255,255,255,.14);
  display:flex;align-items:center;justify-content:center;
  font-weight:700;
  font-size:13px;
  border:1px solid rgba(255,255,255,.25);
  flex-shrink:0;
}
header.topbar .brand-name{
  font-size:14.5px;
  font-weight:600;
  letter-spacing:.2px;
}
header.topbar .nav-links{ display:flex; gap:8px; }
header.topbar .nav-link{
  font-size:13px;
  font-weight:600;
  letter-spacing:.2px;
  color:rgba(255,255,255,.85);
  text-decoration:none;
  padding:7px 14px;
  border-radius:8px;
  border:1px solid rgba(255,255,255,.22);
  transition:background .15s ease, color .15s ease;
}
header.topbar .nav-link:hover{ background:rgba(255,255,255,.12); color:#fff; }

.page-head{
  max-width:1180px;
  margin:0 auto;
  padding:28px clamp(16px,4vw,48px) 0;
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
}
.page-head h1{
  font-size:22px;
  margin:0 0 4px;
  font-weight:700;
  letter-spacing:-.2px;
}
.filters{
  display:flex;
  flex-wrap:wrap;
  gap:16px;
  align-items:flex-end;
  padding:16px 24px;
}
.field{ min-width:190px; }
.field label{
  display:block;
  font-size:12px;
  font-weight:600;
  color:var(--text-muted);
  margin-bottom:6px;
}
.field select{
  width:100%;
  padding:9px 11px;
  border-radius:9px;
  border:1px solid var(--border);
  background:#fbfcfe;
  font-size:13.5px;
  font-family:inherit;
  color:var(--text);
}
.field select:focus{
  outline:none;
  border-color:var(--accent);
  background:#fff;
  box-shadow:0 0 0 3px var(--accent-soft);
}
main{
  max-width:1180px;
  margin:0 auto;
  padding:20px clamp(16px,4vw,48px) 64px;
}

section.panel{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  margin-bottom:28px;
  overflow:hidden;
}
.panel-head{
  display:flex;
  align-items:baseline;
  justify-content:space-between;
  gap:12px;
  padding:20px 24px 16px;
}
.panel-head h2{
  margin:0;
  font-size:16px;
  font-weight:600;
  letter-spacing:.1px;
}
.panel-head .count{
  font-size:12.5px;
  color:var(--text-muted);
  background:var(--bg);
  border:1px solid var(--border);
  padding:3px 10px;
  border-radius:999px;
}
.panel-head p.hint{
  margin:2px 0 0;
  font-size:12.5px;
  color:var(--text-muted);
}
.funding-head-right{
  display:flex;
  align-items:center;
  gap:10px;
}
.funding-scope{
  padding:6px 10px;
  border-radius:8px;
  border:1px solid var(--border);
  background:#fbfcfe;
  font-size:12.5px;
  font-weight:600;
  font-family:inherit;
  color:var(--text);
}
.funding-scope:focus{
  outline:none;
  border-color:var(--accent);
  background:#fff;
  box-shadow:0 0 0 3px var(--accent-soft);
}

.table-scroll{
  overflow-x:auto;
}
table{
  width:100%;
  border-collapse:collapse;
  font-size:13.5px;
}
thead th{
  text-align:left;
  font-size:11.5px;
  text-transform:uppercase;
  letter-spacing:.06em;
  color:var(--text-muted);
  font-weight:600;
  padding:10px 24px;
  border-top:1px solid var(--border);
  border-bottom:1px solid var(--border);
  background:#fafbfd;
  white-space:nowrap;
}
tbody td{
  padding:13px 24px;
  border-bottom:1px solid var(--border);
  vertical-align:top;
  color:var(--text);
}
tbody tr:last-child td{ border-bottom:none; }
tbody tr{ transition:background .12s ease; cursor:pointer; }
tbody tr:hover{ background:#f8faff; }

td.num{ font-variant-numeric:tabular-nums; color:var(--text-muted); white-space:nowrap; }
td.subject{ max-width:340px; font-weight:500; }
td.reason{ color:var(--text-muted); max-width:260px; }
td.when{ color:var(--text-muted); white-space:nowrap; }

.badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  font-size:12px;
  font-weight:600;
  padding:4px 10px;
  border-radius:999px;
  white-space:nowrap;
}
.badge::before{
  content:"";
  width:6px;height:6px;
  border-radius:50%;
}
.badge.taken{ background:var(--warn-soft); color:var(--warn); }
.badge.taken::before{ background:var(--warn); }
.badge.won{ background:var(--ok-soft); color:var(--ok); }
.badge.won::before{ background:var(--ok); }
.badge.declined, .badge.lost{ background:var(--danger-soft); color:var(--danger); }
.badge.declined::before, .badge.lost::before{ background:var(--danger); }

.stats-grid{
  display:flex;
  flex-wrap:wrap;
  gap:14px;
  padding:20px 24px 8px;
}
.stat-card{
  flex:1;
  min-width:170px;
  background:#fafbfd;
  border:1px solid var(--border);
  border-radius:12px;
  padding:14px 16px;
}
.stat-card .stat-label{
  font-size:11.5px;
  font-weight:700;
  color:var(--text-muted);
  text-transform:uppercase;
  letter-spacing:.06em;
  margin-bottom:8px;
}
.stat-card .stat-value{
  font-size:24px;
  font-weight:700;
  letter-spacing:-.3px;
}
.stat-card .stat-sub{
  font-size:12.5px;
  color:var(--text-muted);
  margin-top:2px;
}
.stat-card.budget .stat-value{ color:var(--accent); }
.stat-card.own .stat-value{ color:var(--warn); }
.stat-bar{
  margin:4px 24px 20px;
  height:8px;
  border-radius:999px;
  background:var(--border);
  overflow:hidden;
  display:flex;
}
.stat-bar .seg-budget{ background:var(--accent); }
.stat-bar .seg-own{ background:var(--warn); }
.stat-bar .seg-unknown{ background:#c3cbd8; }

.empty-state{
  padding:48px 24px;
  text-align:center;
  color:var(--text-muted);
  font-size:13.5px;
}
tr.empty-row{ cursor:default; }
tr.empty-row:hover{ background:transparent; }

.skeleton-row td{ padding:14px 24px; }
.skeleton{
  height:12px;
  border-radius:6px;
  background:linear-gradient(90deg,#eef1f6 25%,#f7f8fb 37%,#eef1f6 63%);
  background-size:400% 100%;
  animation:shimmer 1.4s ease infinite;
}
@keyframes shimmer{
  0%{ background-position:100% 50%; }
  100%{ background-position:0 50%; }
}

.toast{
  position:fixed;
  bottom:24px;
  right:24px;
  background:#1a2233;
  color:#fff;
  padding:12px 18px;
  border-radius:10px;
  font-size:13px;
  box-shadow:0 8px 24px rgba(0,0,0,.25);
  max-width:360px;
  display:none;
}
.toast.show{ display:block; }

@media (max-width:640px){
  .page-head{ flex-direction:column; align-items:flex-start; }
  td.subject, td.reason{ max-width:none; }
}
