
:root{
  --navy:#0b1f4d; --navy2:#193a86; --orange:#ff6b1a; --bg:#f4f7fb; --card:#fff;
  --text:#162033; --muted:#6b7280; --line:#e7ebf3; --green:#0f9f63; --amber:#d97706; --red:#dc2626; --blue:#2563eb;
}
*{box-sizing:border-box} html,body{margin:0;padding:0}
body{font-family:Inter,Segoe UI,Arial,sans-serif;background:linear-gradient(180deg,#f8fbff,#f4f7fb);color:var(--text)}
a{text-decoration:none;color:inherit}
.layout{display:flex;min-height:100vh}
.sidebar{width:280px;position:fixed;top:0;left:0;bottom:0;background:linear-gradient(180deg,var(--navy),var(--navy2));color:#fff;padding:20px;overflow:auto}
.logo{display:flex;gap:12px;align-items:center;margin-bottom:22px;text-decoration:none;color:#fff}
.badgeLogo{width:46px;height:46px;border-radius:14px;background:linear-gradient(135deg,var(--orange),#ff934d);display:grid;place-items:center;font-weight:800}
.logo h1{margin:0;font-size:18px}.logo p{margin:4px 0 0;font-size:12px;opacity:.8}
.nav a{display:block;padding:12px 14px;border-radius:12px;margin-bottom:8px;background:rgba(255,255,255,.06);font-size:14px}
.nav a.active,.nav a:hover{background:rgba(255,255,255,.15)}
.sidebox{margin-top:20px;padding:14px;border:1px solid rgba(255,255,255,.14);border-radius:14px;background:rgba(255,255,255,.08);font-size:12px;line-height:1.55}
.main{margin-left:280px;width:calc(100% - 280px); max-width:100%;padding:26px}
.container{max-width:1320px;margin:0 auto}
.reviewbar{background:#fff4ec;border:1px solid #ffd7bb;color:#9a3412;padding:11px 14px;border-radius:12px;font-size:13px;margin-bottom:16px}
.top{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;flex-wrap:wrap;margin-bottom:18px}
.top h2{margin:0;font-size:32px}.top p{margin:8px 0 0;color:var(--muted);max-width:850px;line-height:1.65}
.actions{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.btn{display:inline-flex;align-items:center;justify-content:center;padding:12px 16px;border-radius:14px;border:1px solid var(--line);background:#fff;font-weight:700;cursor:pointer}
.btn.primary{background:linear-gradient(135deg,var(--orange),#ff934d);color:#fff;border:none}
.btn.secondary{background:#eef5ff;border-color:#cfe0ff;color:#1849a9}
.hero{display:grid;grid-template-columns:1.3fr .9fr;gap:18px;background:linear-gradient(135deg,var(--navy),var(--navy2));color:#fff;padding:32px;border-radius:26px;box-shadow:0 18px 45px rgba(11,31,77,.08)}
.hero h1{margin:0 0 12px;font-size:44px;line-height:1.02}.hero p{margin:0;color:rgba(255,255,255,.92);line-height:1.75}
.card{background:#fff;border:1px solid var(--line);border-radius:20px;padding:22px;box-shadow:0 14px 34px rgba(11,31,77,.08)}
.grid4{display:grid;grid-template-columns:repeat(4,1fr);gap:18px;margin-top:18px}
.grid3{display:grid;grid-template-columns:repeat(3,1fr);gap:18px;margin-top:18px}
.grid2{display:grid;grid-template-columns:1.45fr 1fr;gap:18px;margin-top:18px}
.kpi-title{font-size:13px;color:var(--muted);margin-bottom:10px}.kpi-value{font-size:34px;font-weight:800}
.small{font-size:12px}.muted{color:var(--muted)}
.badge{display:inline-block;padding:6px 10px;border-radius:999px;font-size:12px;font-weight:800}
.green{background:#ecfdf3;color:#027a48}.amber{background:#fff7ed;color:#b45309}.red{background:#fef2f2;color:#b91c1c}.blue{background:#eff6ff;color:#1d4ed8}
table{width:100%;border-collapse:collapse} th,td{padding:12px 10px;border-bottom:1px solid var(--line);text-align:left;vertical-align:top;font-size:14px} th{font-size:12px;color:var(--muted);text-transform:uppercase}
.counties{display:grid;grid-template-columns:repeat(5,1fr);gap:12px}.county{background:#fff;border:1px solid var(--line);border-radius:16px;padding:16px}
.form2{display:grid;grid-template-columns:repeat(2,1fr);gap:14px}
label{display:block;font-size:13px;font-weight:700;margin-bottom:6px} input,select,textarea{width:100%;padding:12px 14px;border:1px solid var(--line);border-radius:12px;background:#fff;font:inherit} textarea{min-height:110px}
.progress{width:100%;height:10px;background:#edf1f7;border-radius:999px;overflow:hidden}.progress span{display:block;height:100%;background:linear-gradient(90deg,var(--navy),var(--orange))}
.profile{display:flex;align-items:center;gap:12px}.profile-meta{text-align:right}.profile-name{font-size:13px;font-weight:700}.profile-role{font-size:11px;color:var(--muted)}.profile-avatar{width:42px;height:42px;border-radius:50%;background:linear-gradient(135deg,var(--navy),var(--orange));display:grid;place-items:center;color:#fff;font-weight:800}
.login{min-height:100vh;display:grid;place-items:center;background:linear-gradient(135deg,#f4f8ff,#fff5ef)}
.loginbox{width:min(1080px,94vw);display:grid;grid-template-columns:1.08fr .92fr;background:#fff;border-radius:30px;overflow:hidden;border:1px solid var(--line);box-shadow:0 26px 70px rgba(11,31,77,.12)}
.left{background:linear-gradient(135deg,var(--navy),var(--navy2));color:#fff;padding:42px}.left h1{font-size:44px;line-height:1.03;margin-top:0}.left p{line-height:1.75;color:rgba(255,255,255,.92)}
.right{padding:42px}
.loading-overlay{position:fixed;inset:0;background:rgba(255,255,255,.82);backdrop-filter:blur(4px);display:none;align-items:center;justify-content:center;z-index:9999}
.loading-overlay.show{display:flex}.loading-card{background:#fff;border:1px solid var(--line);border-radius:22px;padding:24px 28px;box-shadow:0 20px 40px rgba(11,31,77,.12);display:flex;align-items:center;gap:16px}.spinner{width:28px;height:28px;border:3px solid #dbe4f3;border-top-color:var(--orange);border-radius:50%;animation:spin .8s linear infinite}@keyframes spin{to{transform:rotate(360deg)}}
canvas{width:100%;height:220px;border:1px solid var(--line);border-radius:14px;background:#fff}
.banner{background:#fff4ec;border:1px solid #ffd7bb;color:#9a3412;padding:14px 16px;border-radius:14px;line-height:1.65}
.metric-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.metric{padding:14px;border-radius:14px;background:#fff;border:1px solid var(--line)}.metric .t{font-size:12px;color:var(--muted)}.metric .v{font-size:24px;font-weight:800;margin-top:6px}
@media (max-width:1100px){.hero,.grid4,.grid3,.grid2,.counties,.form2,.loginbox,.metric-grid{grid-template-columns:1fr}}
@media (max-width:860px){.layout{display:block}.sidebar{position:static;width:100%}.main{margin-left:0;width:100%;padding:18px}}


.hero-visual{
  display:flex;
  align-items:center;
  justify-content:center;
}
.hero-visual img{
  width:100%;
  max-width:520px;
  height:auto;
  display:block;
  border-radius:22px;
  box-shadow:0 18px 45px rgba(11,31,77,.10);
  background:#fff;
}


.insight-card{
  background:linear-gradient(135deg,#fff8f3,#ffffff);
  border:1px solid #ffd7bb;
}
.health-pill{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:74px;
  padding:6px 10px;
  border-radius:999px;
  font-size:12px;
  font-weight:800;
}
.health-pill.good{background:#ecfdf3;color:#027a48}
.health-pill.watch{background:#fff7ed;color:#b45309}
.health-pill.risk{background:#fef2f2;color:#b91c1c}
.map-panel{
  background:linear-gradient(135deg,#f8fbff,#ffffff);
}
.map-note{
  margin-top:10px;
  font-size:12px;
  color:var(--muted);
}
.download-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:14px;
}
.role-chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:7px 11px;
  border-radius:999px;
  background:#eef5ff;
  color:#1849a9;
  border:1px solid #cfe0ff;
  font-size:12px;
  font-weight:700;
}
.teaser{
  background:linear-gradient(135deg,#eef5ff,#ffffff);
  border:1px solid #cfe0ff;
}


/* ===== responsive enhancement patch ===== */
html, body {
  overflow-x: hidden;
}

img, svg, canvas {
  max-width: 100%;
  height: auto;
}

.container {
  width: 100%;
}

.top,
.topbar {
  align-items: flex-start;
}

.actions {
  row-gap: 10px;
}

.card,
.hero,
.county,
.metric,
.hero-card,
.hero-mini {
  min-width: 0;
}

table {
  width: 100%;
}

.table-wrap,
.card table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.card table {
  white-space: nowrap;
}

textarea,
input,
select,
button,
.btn {
  max-width: 100%;
}

@media (max-width: 1180px) {
  .hero,
  .hero-meta,
  .grid4,
  .grid3,
  .grid2,
  .counties,
  .form2,
  .metric-grid,
  .loginbox {
    grid-template-columns: 1fr !important;
  }

  .hero {
    padding: 26px;
  }

  .hero h1 {
    max-width: 100%;
  }
}

@media (max-width: 900px) {
  .layout {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    z-index: 50;
    padding: 14px 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
  }

  .main {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 16px;
  }

  .logo {
    margin-bottom: 14px;
  }

  .logo h1 {
    font-size: 17px;
  }

  .logo p {
    font-size: 11px;
  }

  .nav {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .nav a {
    margin-bottom: 0;
    font-size: 14px;
  }

  .sidebox {
    margin-top: 14px;
    font-size: 11px;
  }

  .top h2,
  .topbar h2 {
    font-size: 28px;
    line-height: 1.08;
  }

  .hero h1 {
    font-size: 34px;
    line-height: 1.08;
  }

  .hero p {
    font-size: 15px;
  }

  .actions {
    width: 100%;
    justify-content: flex-start;
  }

  .profile {
    width: 100%;
    justify-content: flex-start;
  }

  .profile-meta {
    text-align: left;
  }

  .reviewbar {
    font-size: 12px;
    line-height: 1.5;
  }

  .card,
  .county {
    padding: 18px;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 12px;
  }

  .container {
    max-width: 100%;
  }

  .hero {
    padding: 20px;
    border-radius: 20px;
  }

  .hero h1 {
    font-size: 28px;
    line-height: 1.1;
  }

  .top h2,
  .topbar h2 {
    font-size: 24px;
  }

  .card {
    padding: 16px;
    border-radius: 16px;
  }

  .counties {
    gap: 10px;
  }

  .grid4,
  .grid3,
  .grid2,
  .form2,
  .metric-grid {
    gap: 12px;
    margin-top: 12px;
  }

  .btn {
    width: 100%;
    min-height: 46px;
    padding: 12px 14px;
  }

  .actions .btn {
    flex: 1 1 100%;
  }

  .profile {
    margin-top: 4px;
  }

  .profile-avatar {
    width: 38px;
    height: 38px;
    font-size: 13px;
  }

  .profile-name {
    font-size: 12px;
  }

  .profile-role {
    font-size: 10px;
  }

  .reviewbar {
    padding: 10px 12px;
  }

  .banner,
  .info {
    padding: 12px 14px;
    font-size: 13px;
  }

  .kpi-value {
    font-size: 28px;
  }

  th,
  td {
    padding: 10px 8px;
    font-size: 13px;
  }

  th {
    font-size: 11px;
  }

  .hero-mini .v,
  .metric .v {
    font-size: 22px;
  }

  .left,
  .right {
    padding: 24px;
  }

  .left h1 {
    font-size: 30px;
    line-height: 1.08;
  }

  .loginbox {
    border-radius: 20px;
  }

  .loading-card {
    width: min(92vw, 420px);
    padding: 18px 20px;
  }
}

@media (max-width: 420px) {
  .sidebar {
    padding: 12px;
  }

  .main {
    padding: 10px;
  }

  .hero {
    padding: 16px;
  }

  .hero h1 {
    font-size: 24px;
  }

  .top h2,
  .topbar h2 {
    font-size: 22px;
  }

  .logo-badge,
  .badgeLogo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 16px;
  }

  .nav a {
    padding: 11px 12px;
    font-size: 13px;
  }

  .card {
    padding: 14px;
  }

  .kpi-value {
    font-size: 24px;
  }

  .hero-mini,
  .metric {
    padding: 12px;
  }

  .btn {
    font-size: 14px;
  }
}


/* ===== clean nav usability patch ===== */
html { scroll-behavior: smooth; }
body { overflow-x: hidden; }

.sidebar .logout-link{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:12px 14px;
  margin-top:12px;
  border-radius:12px;
  background:rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.12);
  color:#fff;
  font-weight:700;
}

.top-actions-nav{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:8px;
}
.top-actions-nav a{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  font-size:13px;
  font-weight:700;
  box-shadow:0 8px 18px rgba(11,31,77,.04);
}

.page-footer-nav{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  margin-top:18px;
}
.page-footer-nav a{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:11px 14px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  font-size:13px;
  font-weight:700;
}

.floating-top{
  position:fixed;
  right:18px;
  bottom:18px;
  width:46px;
  height:46px;
  border-radius:50%;
  background:linear-gradient(135deg,var(--navy),var(--orange));
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:20px;
  font-weight:800;
  box-shadow:0 14px 26px rgba(11,31,77,.18);
  z-index:60;
}

@media (max-width: 900px){
  .top-actions-nav a,
  .page-footer-nav a{
    flex:1 1 calc(50% - 8px);
  }
}
@media (max-width: 640px){
  .top-actions-nav a,
  .page-footer-nav a{
    flex:1 1 100%;
  }
  .floating-top{
    right:12px;
    bottom:12px;
    width:42px;
    height:42px;
  }
}


/* ===== desktop sidebar/content spacing fix ===== */
:root{
  --sidebar-w: 280px;
  --main-gutter: 24px;
}

.sidebar{
  width: var(--sidebar-w) !important;
}

.main{
  margin-left: calc(var(--sidebar-w) + var(--main-gutter)) !important;
  width: calc(100% - var(--sidebar-w) - var(--main-gutter)) !important;
  max-width: none !important;
  padding-left: 12px !important;
}

.container{
  max-width: 1280px !important;
  width: 100% !important;
}

.hero,
.grid4,
.grid3,
.grid2,
.counties,
.form2,
.metric-grid{
  width: 100% !important;
}

.card,
.hero,
.county{
  overflow: hidden;
}

@media (max-width: 900px){
  .main{
    margin-left: 0 !important;
    width: 100% !important;
    padding-left: 0 !important;
  }
}


/* FINAL SIDEBAR FIX */
.sidebar{
  width:260px !important;
  position:fixed;
  top:0;
  left:0;
  bottom:0;
  overflow:auto;
}

.main{
  margin-left:260px !important;
  width:calc(100% - 260px) !important;
  padding:24px !important;
}

.container{
  width:100% !important;
  max-width:none !important;
}

.hero,
.grid4,
.grid3,
.grid2,
.counties,
.form2,
.metric-grid,
.card{
  max-width:100% !important;
  min-width:0 !important;
}

body{
  overflow-x:hidden;
}

@media (max-width: 900px){
  .sidebar{
    position:static !important;
    width:100% !important;
  }

  .main{
    margin-left:0 !important;
    width:100% !important;
    padding:16px !important;
  }
}


/* ===== PREMIUM FINAL LAYOUT FIX ===== */
:root{
  --sidebar-w: 260px;
  --sidebar-gap: 28px;
  --mobile-header-h: 62px;
}

/* desktop layout */
.sidebar{
  width: var(--sidebar-w) !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  bottom: 0 !important;
  z-index: 1000 !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  box-shadow: 8px 0 28px rgba(11,31,77,.10);
}

.main{
  margin-left: calc(var(--sidebar-w) + var(--sidebar-gap)) !important;
  width: auto !important;
  max-width: none !important;
  padding: 24px 24px 32px 0 !important;
}

.container{
  width: 100% !important;
  max-width: 1280px !important;
  margin: 0 auto !important;
}

body{
  overflow-x: hidden !important;
}

.hero,
.grid4,
.grid3,
.grid2,
.counties,
.form2,
.metric-grid{
  width: 100% !important;
  min-width: 0 !important;
}

.card,
.hero,
.county{
  overflow: hidden;
}

.nav a{
  position: relative;
}
.nav a.active::before{
  content:"";
  position:absolute;
  left:0;
  top:10px;
  bottom:10px;
  width:4px;
  border-radius:999px;
  background: linear-gradient(180deg, var(--orange), #ff9b57);
}

.logout-link{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:12px 14px;
  margin-top:12px;
  border-radius:12px;
  background:rgba(255,255,255,.10);
  border:1px solid rgba(255,255,255,.12);
  color:#fff !important;
  font-weight:700;
}

.page-footer-nav{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
  margin-top:20px;
}
.page-footer-nav a{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:11px 14px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  font-size:13px;
  font-weight:700;
  box-shadow:0 8px 18px rgba(11,31,77,.04);
}

.floating-top{
  position:fixed;
  right:18px;
  bottom:18px;
  width:46px;
  height:46px;
  border-radius:50%;
  background:linear-gradient(135deg,var(--navy),var(--orange));
  color:#fff !important;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:20px;
  font-weight:800;
  box-shadow:0 14px 26px rgba(11,31,77,.18);
  z-index:1100;
}

/* mobile polish */
.mobile-topbar{
  display:none;
}

.mobile-backdrop{
  display:none;
}

@media (max-width: 900px){
  .mobile-topbar{
    position: sticky;
    top: 0;
    z-index: 1200;
    height: var(--mobile-header-h);
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding: 12px 14px;
    background: rgba(11,31,77,.96);
    color:#fff;
    backdrop-filter: blur(8px);
    box-shadow:0 10px 24px rgba(11,31,77,.18);
  }

  .mobile-brand{
    display:flex;
    align-items:center;
    gap:10px;
    min-width:0;
  }

  .mobile-brand .brand-text{
    font-size:15px;
    font-weight:800;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
  }

  .menu-toggle{
    width:42px;
    height:42px;
    border-radius:12px;
    border:1px solid rgba(255,255,255,.14);
    background:rgba(255,255,255,.10);
    color:#fff;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:22px;
    cursor:pointer;
  }

  .sidebar{
    transform: translateX(-100%);
    transition: transform .22s ease;
    width: min(84vw, 320px) !important;
    box-shadow: 12px 0 28px rgba(11,31,77,.18);
  }

  body.sidebar-open .sidebar{
    transform: translateX(0);
  }

  .mobile-backdrop{
    position: fixed;
    inset: 0;
    background: rgba(11,31,77,.34);
    z-index: 999;
  }

  body.sidebar-open .mobile-backdrop{
    display:block;
  }

  .main{
    margin-left: 0 !important;
    width: 100% !important;
    padding: 14px !important;
  }

  .container{
    max-width: 100% !important;
  }

  .reviewbar{
    margin-top: 0;
  }

  .hero{
    padding: 22px;
    border-radius: 22px;
  }

  .hero h1{
    font-size: 32px !important;
  }

  .top h2, .topbar h2{
    font-size: 26px !important;
  }

  .profile{
    width:100%;
    justify-content:flex-start;
  }

  .profile-meta{
    text-align:left;
  }

  .page-footer-nav a{
    flex: 1 1 calc(50% - 10px);
  }
}

@media (max-width: 640px){
  .hero{
    padding: 18px;
  }

  .hero h1{
    font-size: 28px !important;
    line-height: 1.1 !important;
  }

  .top h2, .topbar h2{
    font-size: 22px !important;
  }

  .btn{
    width:100%;
  }

  .actions .btn{
    flex: 1 1 100%;
  }

  .page-footer-nav a{
    flex: 1 1 100%;
  }

  .floating-top{
    right: 12px;
    bottom: 12px;
    width: 42px;
    height: 42px;
  }

  .main{
    padding: 10px !important;
  }
}


/* ===== GRID LAYOUT HARD FIX ===== */
@media (min-width: 901px){
  body{
    overflow-x: hidden !important;
  }

  .layout{
    display: grid !important;
    grid-template-columns: 244px minmax(0, 1fr) !important;
    min-height: 100vh !important;
  }

  .sidebar{
    position: sticky !important;
    top: 0 !important;
    left: auto !important;
    bottom: auto !important;
    width: 244px !important;
    height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 16px 14px 18px !important;
    box-sizing: border-box !important;
    z-index: 10 !important;
  }

  .main{
    margin-left: 0 !important;
    width: auto !important;
    max-width: none !important;
    padding: 18px 20px 28px 20px !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
  }

  .container{
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    min-width: 0 !important;
  }

  .hero,
  .grid2,
  .grid3,
  .grid4,
  .counties,
  .form2,
  .metric-grid,
  .card,
  table{
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}

@media (max-width: 900px){
  .layout{
    display: block !important;
  }

  .sidebar{
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    transform: translateX(-100%);
  }

  body.sidebar-open .sidebar{
    transform: translateX(0);
  }

  .main{
    margin-left: 0 !important;
    width: 100% !important;
    padding: 14px !important;
  }
}
