:root {
  --ink: #18252d;
  --muted: #66767f;
  --line: #d9e1e4;
  --surface: #ffffff;
  --page: #f4f7f8;
  --orange: #f05a18;
  --orange-soft: #fff0e8;
  --teal: #087b83;
  --teal-soft: #e6f5f4;
  --blue: #1672b7;
  --blue-soft: #eaf4fb;
  --red: #bd3227;
  --red-soft: #fff0ee;
  --green: #277443;
  --green-soft: #eaf6ed;
  --shadow: 0 12px 28px rgba(26, 42, 50, 0.09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--page); }
body {
  margin: 0;
  min-width: 0;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { letter-spacing: 0; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef3f3;
  transition: opacity 160ms ease, transform 160ms ease;
}
.login-shell.is-leaving { opacity: 0; transform: translateY(-8px); }
.login-panel {
  width: min(100%, 420px);
  padding: 34px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--orange);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-brand, .app-brand { margin: 0; color: var(--ink); font-size: 21px; font-weight: 800; }
.login-heading { margin: 38px 0 26px; }
.login-heading h1 { max-width: 260px; margin: 7px 0 0; font-size: 29px; line-height: 1.12; }
.eyebrow { margin: 0; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: 0; }
form { display: grid; gap: 9px; }
label { margin-top: 8px; color: #2c3941; font-size: 13px; font-weight: 800; }
input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #b9c5ca;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
  outline: none;
}
input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px #cdebea; }
button[type="submit"] {
  min-height: 48px;
  margin-top: 18px;
  border: 0;
  border-radius: 5px;
  color: #fff;
  background: var(--ink);
  font-weight: 800;
}
button[type="submit"]:hover { background: #2a3a44; }
button[type="submit"]:disabled { cursor: wait; opacity: 0.7; }
.form-error {
  display: none;
  margin: 13px 0 0;
  padding: 10px 12px;
  border: 1px solid #f6b9b2;
  border-radius: 5px;
  color: #9b2d24;
  background: var(--red-soft);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}
.form-error:not([hidden]) { display: block; }

.dashboard-shell { min-height: 100vh; padding-bottom: 34px; }
.app-frame { width: min(100% - 40px, 1320px); margin: 0 auto; }
.app-header { border-bottom: 1px solid var(--line); background: var(--surface); }
.header-content { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.session-actions { display: flex; align-items: center; gap: 12px; }
.user-summary { display: grid; gap: 3px; text-align: right; font-size: 13px; }
.user-summary span { color: var(--muted); }
.logout-button {
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid #b7c3c8;
  border-radius: 5px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}
.logout-button:hover { border-color: var(--ink); background: #f3f6f7; }
.app-nav { position: sticky; z-index: 3; top: 0; border-bottom: 1px solid var(--line); background: rgba(255, 255, 255, 0.96); }
.nav-list { display: flex; gap: 4px; overflow-x: auto; }
.nav-button {
  min-height: 48px;
  padding: 0 15px;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}
.nav-button:hover { color: var(--ink); }
.nav-button.is-active { border-bottom-color: var(--orange); color: var(--ink); }
.app-content { padding-top: 30px; }
.app-page { display: none; animation: page-in 180ms ease both; }
.app-page.is-active { display: block; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.context-strip {
  display: flex;
  align-items: center;
  gap: 30px;
  min-height: 64px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.context-strip > div { display: grid; gap: 4px; }
.context-strip span { color: var(--muted); font-size: 11px; font-weight: 800; }
.context-strip strong { font-size: 14px; }
.data-mode { margin: 0 0 0 auto; color: var(--teal); font-size: 12px; font-weight: 800; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin: 28px 0 16px; }
.page-heading h2 { margin: 6px 0 0; font-size: 25px; }
.page-subtitle { max-width: 360px; margin: 0; color: var(--muted); font-size: 13px; text-align: right; }
.count-label { color: var(--muted); font-size: 12px; font-weight: 800; }

.goal-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.goal-card { min-height: 212px; padding: 19px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 2px 5px rgba(26, 42, 50, 0.03); }
.goal-card.coverage { border-top: 4px solid var(--orange); }
.goal-card.repurchase { border-top: 4px solid var(--teal); }
.goal-card.billing { border-top: 4px solid var(--blue); }
.goal-card-label { display: block; color: var(--muted); font-size: 11px; font-weight: 800; }
.goal-card-value { display: block; margin-top: 18px; font-size: 31px; line-height: 1; }
.goal-card-detail { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }
.progress-track { height: 8px; margin: 19px 0 10px; overflow: hidden; border-radius: 999px; background: #e8eef0; }
.progress-track span { display: block; height: 100%; border-radius: inherit; }
.coverage .progress-track span { background: var(--orange); }
.repurchase .progress-track span { background: var(--teal); }
.billing .progress-track span { background: var(--blue); }
.goal-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; }
.goal-percent { color: var(--ink); font-weight: 800; }
.goal-gap { margin: 0; color: var(--muted); font-size: 12px; font-weight: 700; }
.goal-gap.is-complete { color: var(--green); }

.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 2px 5px rgba(26, 42, 50, 0.03); }
.ranking-panel { margin-top: 14px; }
.panel-heading { min-height: 76px; padding: 16px 19px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 6px 0 0; font-size: 18px; }
.ranking-content { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.ranking-item { min-height: 185px; padding: 20px; border-right: 1px solid var(--line); }
.ranking-item:last-child { border-right: 0; }
.ranking-item > p { margin-bottom: 17px; color: var(--muted); font-size: 12px; font-weight: 800; }
.ranking-number { display: flex; align-items: end; gap: 8px; margin-bottom: 16px; }
.ranking-number strong { font-size: 38px; line-height: 0.9; }
.ranking-number span { color: var(--muted); font-size: 12px; font-weight: 700; }
.ranking-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.ranking-details > div { display: grid; gap: 4px; }
.ranking-details span { color: var(--muted); font-size: 11px; font-weight: 800; }
.ranking-details strong { font-size: 14px; }
.status { display: inline-flex; width: max-content; align-items: center; min-height: 24px; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.status.yes { color: var(--green); background: var(--green-soft); }
.status.no { color: var(--red); background: var(--red-soft); }
.empty-state { margin: 0; padding: 28px 20px; color: var(--muted); font-size: 13px; }

.opportunities-list { display: grid; gap: 12px; }
.download-group { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.download-group summary { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 76px; padding: 18px; cursor: pointer; list-style: none; }
.download-group summary::-webkit-details-marker { display: none; }
.download-group summary::after { content: "+"; color: var(--teal); font-size: 24px; font-weight: 400; }
.download-group[open] summary::after { content: "-"; }
.download-group h3 { margin: 0; font-size: 17px; }
.download-group p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.download-actions { display: flex; gap: 10px; padding: 0 18px 18px; }
.download-button { min-height: 40px; padding: 0 14px; border: 1px solid #b8c7cc; border-radius: 5px; color: var(--ink); background: #fff; font-size: 12px; font-weight: 800; }
.download-button:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.download-button:disabled { cursor: wait; opacity: 0.65; }

.table-wrap { overflow-x: auto; }
.team-mobile-list, .access-mobile-list { display: none; }
table { width: 100%; min-width: 1510px; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid #e4eaec; text-align: left; white-space: nowrap; font-size: 12px; }
th { color: var(--muted); background: #f5f8f9; font-size: 11px; font-weight: 800; }
thead tr:first-child th[colspan] { border-bottom: 1px solid #cfd9dd; color: var(--ink); text-align: center; }
td:first-child { font-weight: 800; }
td:first-child span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-weight: 500; }
.percent-value { color: var(--teal); font-weight: 800; }
.presale-value { color: var(--orange); font-weight: 800; }
.rank-value { color: var(--blue); font-weight: 800; }
.empty-row { color: var(--muted); text-align: center; }
tbody tr:hover { background: #f7fafb; }

@media (max-width: 880px) {
  .goal-cards { grid-template-columns: 1fr; }
  .goal-card { min-height: 180px; }
  .ranking-content { grid-template-columns: 1fr; }
  .ranking-item { border-right: 0; border-bottom: 1px solid var(--line); }
  .ranking-item:last-child { border-bottom: 0; }
}

@media (max-width: 600px) {
  .login-shell { align-items: start; padding: 16px; }
  .login-panel { margin-top: 7vh; padding: 26px 22px; }
  .login-heading { margin: 31px 0 24px; }
  .login-heading h1 { font-size: 26px; }
  .app-frame { width: min(100% - 24px, 1320px); }
  .header-content { min-height: 66px; }
  .app-brand { font-size: 18px; }
  .user-summary { max-width: 150px; overflow: hidden; }
  .user-summary strong, .user-summary span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .logout-button { min-width: 44px; padding: 0 8px; }
  .nav-list { width: 100%; }
  .nav-button { min-height: 45px; padding: 0 12px; font-size: 12px; }
  .app-content { padding-top: 18px; }
  .context-strip { gap: 17px; min-height: 0; flex-wrap: wrap; }
  .data-mode { width: 100%; margin-left: 0; }
  .page-heading { align-items: start; margin: 22px 0 13px; }
  .page-heading h2 { font-size: 22px; }
  .page-subtitle { display: none; }
  .goal-cards { gap: 10px; }
  .goal-card { min-height: 168px; padding: 16px; }
  .goal-card-value { font-size: 28px; }
  .ranking-item { min-height: 0; padding: 17px; }
  .download-group summary { min-height: 68px; padding: 15px; }
  .download-actions { padding: 0 15px 15px; }
  .download-button { flex: 1; padding: 0 8px; }
  .table-wrap { display: none; }
  .team-mobile-list, .access-mobile-list { display: grid; }
  .team-mobile-card, .access-mobile-card { padding: 15px; border-bottom: 1px solid var(--line); }
  .team-mobile-card:last-child, .access-mobile-card:last-child { border-bottom: 0; }
  .team-mobile-card > div, .access-mobile-card { display: grid; gap: 4px; }
  .team-mobile-card > div > span, .access-mobile-card span, .access-mobile-card time { color: var(--muted); font-size: 11px; }
  .mobile-metrics { display: grid; gap: 14px; margin-top: 17px; }
  .mobile-metric { padding-top: 13px; border-top: 1px solid #e4eaec; }
  .mobile-metric h3 { margin: 0 0 9px; font-size: 12px; }
  .mobile-metric dl, .team-mobile-card .mobile-ranking { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin: 0; }
  .team-mobile-card .mobile-ranking { margin-top: 16px; padding-top: 14px; border-top: 1px solid #e4eaec; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .team-mobile-card dt { color: var(--muted); font-size: 10px; font-weight: 800; }
  .team-mobile-card dd { margin: 4px 0 0; font-size: 13px; font-weight: 800; }
  .mobile-metric dd { font-size: 12px; }
  .team-mobile-card .status { margin-top: 3px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
