:root {
  --ink: #132a32;
  --muted: #64747a;
  --paper: #f5f3ed;
  --surface: #ffffff;
  --line: #dfe3df;
  --navy: #173b43;
  --teal: #147d72;
  --teal-dark: #0d625a;
  --mint: #dbece5;
  --amber: #c8862b;
  --red: #b94a48;
  --green: #2c7a5c;
  --shadow: 0 18px 50px rgba(26, 48, 52, 0.08);
  --radius: 18px;
}

html {
  font-size: 16px;
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, Aptos, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--teal-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover { color: var(--ink); }

h1, h2, h3 {
  letter-spacing: -0.035em;
  line-height: 1.06;
  margin-top: 0;
}

h1 { font-size: clamp(2.2rem, 4vw, 4.1rem); font-weight: 680; }
h2 { font-size: clamp(1.55rem, 2.5vw, 2.25rem); font-weight: 660; }
h3 { font-size: 1.15rem; font-weight: 650; }
p { color: var(--muted); line-height: 1.7; }

.eyebrow {
  display: inline-block;
  margin-bottom: .8rem;
  color: var(--teal);
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.muted { color: var(--muted); }

.topbar {
  position: sticky;
  z-index: 100;
  top: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  min-height: 76px;
  padding: 0 clamp(1rem, 3vw, 3rem);
  border-bottom: 1px solid rgba(19, 42, 50, .12);
  background: rgba(245, 243, 237, .94);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover { color: var(--ink); }
.brand > span:last-child { display: flex; align-items: baseline; }
.brand strong { font-size: 1.02rem; letter-spacing: -.02em; }
.brand small { margin-left: .23rem; color: var(--teal); font-size: .72rem; font-weight: 800; letter-spacing: .08em; }

.brand-mark {
  display: grid;
  width: 37px;
  height: 37px;
  place-items: center;
  border-radius: 11px 4px 11px 4px;
  color: white;
  background: var(--teal);
  font-family: Georgia, serif;
  font-size: 1.3rem;
}

.app-navigation {
  justify-self: center;
  align-items: center;
}

.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 2000; padding: .75rem 1rem; color: var(--ink); background: white; }
.skip-link:focus { top: .5rem; }
.nav-group-toggle, .account-toggle { min-height: 44px; padding: .6rem .65rem; border: 0; border-radius: 9px; color: #3c5158; background: transparent; font: inherit; font-size: .84rem; font-weight: 620; }
.nav-group-toggle:hover, .account-toggle:hover { background: var(--mint); }
.app-navigation a[aria-current="page"] { color: var(--teal-dark); background: var(--mint); text-decoration: underline; }
.app-navigation .dropdown-menu { min-width: 13rem; border-color: var(--line); }
.app-navigation .dropdown-item { display: block; width: auto; }
.app-navigation > a { white-space: nowrap; }
.user-menu .button-link { min-height: 44px; padding: .5rem; white-space: nowrap; }

.app-navigation.collapse:not(.show) { display: flex; }

.app-navigation a {
  margin: 0 .12rem;
  padding: .6rem .65rem;
  border-radius: 9px;
  color: #3c5158;
  font-size: .84rem;
  font-weight: 620;
  text-decoration: none;
}

.app-navigation a:hover {
  color: var(--ink);
  background: rgba(20, 125, 114, .09);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: .65rem;
  font-size: .82rem;
}

.user-menu form { margin: 0; }
.user-avatar { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: white; background: var(--navy); font-weight: 700; }
.user-name { max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.button-link { padding: .25rem; border: 0; color: var(--muted); background: transparent; font: inherit; text-decoration: underline; text-underline-offset: 3px; }
.nav-toggle { display: none; justify-self: end; width: 42px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.nav-toggle span { display: block; width: 18px; height: 2px; margin: 4px auto; background: var(--ink); }

.app-main {
  width: min(1420px, calc(100% - 2rem));
  min-height: calc(100vh - 150px);
  margin: 0 auto;
  padding: clamp(2rem, 4vw, 4rem) 0 4rem;
}

.public-main {
  width: 100%;
  min-height: calc(100vh - 52px);
  padding: 0;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  width: min(1420px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.3rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .78rem;
}

.page-heading { margin-bottom: 2.25rem; }
.page-heading p { max-width: 710px; margin-bottom: 0; font-size: 1.02rem; }
.split-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.split-heading h1 { max-width: 760px; }

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.metric-card {
  position: relative;
  min-height: 160px;
  padding: 1.4rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(26, 48, 52, .04);
}

.metric-card::after { content: ""; position: absolute; width: 90px; height: 90px; right: -25px; bottom: -30px; border-radius: 50%; background: currentColor; opacity: .08; }
.metric-card span { color: var(--muted); font-size: .77rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.metric-card strong { display: block; margin-top: 1.25rem; color: var(--ink); font-family: Georgia, serif; font-size: 3.15rem; font-weight: 500; line-height: 1; }
.tone-navy { color: var(--navy); }
.tone-amber { color: var(--amber); }
.tone-green { color: var(--green); }
.tone-red { color: var(--red); }

.surface-card {
  margin-top: 1rem;
  padding: clamp(1.2rem, 2.5vw, 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.3rem; }
.section-heading h2 { margin-bottom: 0; }
.section-heading .eyebrow { margin-bottom: .45rem; }
.empty-state { padding: 3.5rem 1rem; text-align: center; }
.empty-state p { margin: 0 auto; max-width: 500px; }
.empty-icon { display: grid; width: 54px; height: 54px; margin: 0 auto 1rem; place-items: center; border-radius: 50%; color: var(--teal); background: var(--mint); font-size: 1.4rem; }

/* Keep absolutely positioned screen-reader headings inside their scrolling table. */
.table-responsive { position: relative; }
.app-table { margin: 0; vertical-align: middle; }
.app-table thead th { padding: .8rem .75rem; border-bottom-color: var(--line); color: var(--muted); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.app-table tbody td { padding: 1rem .75rem; border-bottom-color: #edf0ed; color: #3d5157; }
.status-pill { display: inline-flex; padding: .3rem .6rem; border-radius: 999px; color: var(--teal-dark); background: var(--mint); font-size: .72rem; font-weight: 700; }

.btn { border-radius: 10px; font-weight: 680; }
.btn-primary { border-color: var(--teal); background: var(--teal); box-shadow: 0 7px 18px rgba(20, 125, 114, .18); }
.btn-primary:hover, .btn-primary:focus { border-color: var(--teal-dark); background: var(--teal-dark); }
.btn-lg { padding: .85rem 1.25rem; font-size: .95rem; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid rgba(20, 125, 114, .35); outline-offset: 2px; box-shadow: none; }

.form-field { margin-bottom: 1.15rem; }
.form-field label, .field-label-row label { margin-bottom: .42rem; color: #344a51; font-size: .8rem; font-weight: 700; }
.form-field input, .form-field select, .form-field textarea, .form-control, .form-select {
  display: block;
  width: 100%;
  padding: .78rem .85rem;
  border: 1px solid #cbd4d1;
  border-radius: 10px;
  color: var(--ink);
  background: #fbfcfa;
}
.form-field span.field-validation-error { display: block; margin-top: .35rem; color: var(--red); font-size: .76rem; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; }
.field-label-row a { font-size: .75rem; }
.check-row { display: flex; align-items: center; gap: .55rem; margin: .3rem 0 1.35rem; color: var(--muted); font-size: .8rem; }
.validation-summary { margin-bottom: 1rem; color: var(--red); font-size: .83rem; }
.validation-summary ul { margin: 0; padding-left: 1.25rem; }

.auth-shell { display: grid; min-height: calc(100vh - 52px); grid-template-columns: 1.08fr .92fr; }
.auth-story { display: flex; flex-direction: column; justify-content: space-between; min-height: 720px; padding: clamp(2rem, 5vw, 5.2rem); color: white; background: radial-gradient(circle at 80% 12%, rgba(77, 180, 157, .28), transparent 30%), linear-gradient(145deg, #102e35 0%, #174850 58%, #116c64 100%); }
.brand-light { color: white; }
.brand-light:hover { color: white; }
.auth-story .brand-mark { color: var(--navy); background: #edf7f2; }
.auth-story .brand small, .auth-story .eyebrow { color: #91d9c8; }
.auth-story h1 { margin: 1rem 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3.2rem, 7vw, 6.7rem); font-weight: 400; letter-spacing: -.055em; }
.auth-story p { max-width: 690px; color: rgba(255,255,255,.72); font-size: clamp(1rem, 1.5vw, 1.2rem); }
.auth-benefits { display: grid; margin: 0; padding: 0; gap: .65rem; list-style: none; color: rgba(255,255,255,.82); font-size: .84rem; }
.auth-benefits span { display: inline-block; width: 2.2rem; color: #91d9c8; font-family: Georgia, serif; }
.auth-panel { display: grid; padding: clamp(1.5rem, 5vw, 6rem); place-items: center; background: #f4f1ea; }
.auth-card { width: min(430px, 100%); }
.auth-card h2 { margin-bottom: .55rem; font-size: 2.15rem; }
.auth-card > p { margin-bottom: 2rem; }

.narrow-page { display: grid; min-height: calc(100vh - 100px); padding: 2rem 1rem; place-items: center; }
.form-card { width: min(620px, 100%); padding: clamp(1.5rem, 5vw, 3.5rem); }
.form-card h1 { font-size: clamp(2rem, 4vw, 3rem); }
.app-alert { width: min(850px, 100%); margin: 0 auto 1rem; border-radius: 12px; }

@media (max-width: 1160px) {
  .topbar { grid-template-columns: auto auto 1fr; }
  .nav-toggle { display: block; }
  .app-navigation { position: absolute; top: 68px; left: 1rem; right: 1rem; padding: .7rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
  .app-navigation.collapse:not(.show) { display: none; }
  .app-navigation.show { display: grid; }
  .app-navigation a { padding: .75rem; }
  .app-navigation { max-height: calc(100vh - 90px); overflow-y: auto; }
  .nav-group-toggle { width: 100%; text-align: left; }
  .app-navigation .dropdown-menu { position: static !important; transform: none !important; border: 0; padding-left: .75rem; }
  .user-menu { justify-self: end; }
}

@media (max-width: 860px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-panel { order: -1; min-height: auto; padding-top: 2.5rem; padding-bottom: 2.5rem; }
  .auth-story { min-height: auto; gap: 2rem; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 .8rem; }
  .user-name { display: none; }
  .topbar { gap: .35rem; }
  .topbar .brand strong { font-size: .9rem; }
  .user-menu { gap: 0; }
  .account-toggle { padding: .5rem .25rem; font-size: .75rem; }
  .user-menu .button-link { font-size: .75rem; }
  .app-main { width: min(100% - 1rem, 1420px); padding-top: 1.5rem; }
  .split-heading, .section-heading { align-items: stretch; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .metric-card { min-height: 130px; padding: 1rem; }
  .metric-card strong { font-size: 2.45rem; }
  .surface-card { padding: 1rem; border-radius: 14px; }
  .auth-story { min-height: auto; padding: 2rem 1.3rem; }
  .auth-panel { min-height: auto; padding: 2rem 1.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
