:root{
    --bg1:#f7f7fb;
    --bg2:#ffffff;
    --text:#111;
    --muted:#666;
    --border:#e6e6ef;
    --shadow: 0 1px 2px rgba(0,0,0,.06);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
    margin:0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
    color:var(--text);
    background: linear-gradient(180deg, var(--bg1), var(--bg2));
    font-size:20px;
}

.nav{
    position:sticky; top:0; z-index:30;
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,.9);
    border-bottom:1px solid var(--border);
}
.nav-inner{
    max-width:1700px;
    height:56px;
    margin:0 auto;
    padding:0 16px;
    display:flex;
    align-items:center;
    justify-content:space-between;
}
.nav-left{ display:flex; align-items:center; gap:12px; }
.nav-logo{ width:32px; height:32px; border-radius:12px; background:#111; }
.nav-title{ font-weight:700; font-size:16px; }
.nav-crumb{ font-size:15px; color:var(--muted); }

.hero h1{ margin:0; font-size:28px; }
.subtitle{ margin:6px 0 0; color:var(--muted); font-size:20px; }
.small{ margin:8px 0 0; color:var(--muted); font-size:16px; }

.controls-title{ font-weight:700; font-size:22px; margin-bottom:6px; }
.control{ display:flex; flex-direction:column; gap:6px; font-size:14px; }

.control select, .control input[type="range"], .search input{
    border:1px solid var(--border);
    border-radius:12px;
    padding:10px 12px;
    font-size:20px;
}

.search-input{
    padding-bottom: 10px;
}

.ticks{ font-size:13px; color:var(--muted); }

.badge-title{ font-weight:700; font-size:14px; }
.badge-sub{ font-size:13px; color:var(--muted); margin-top:3px; }

.legend{ font-size:13px; color:#444; }
.legend-title{ font-weight:700; font-size:14px; margin-bottom:4px; }
.legend-section{ margin-top:6px; }
.legend-subtitle{ font-weight:600; font-size:12px; color:#333; margin-bottom:4px; }
.legend-note{ font-size:11px; color:#444; }

.legend-svg{
    width: 100%;
    height: auto;
    display:block;
}


.side-title{ font-weight:700; font-size:15px; }
.side-name{ font-weight:700; font-size:18px; margin-top:6px; }

.meta{ font-size:13px; color:#333; }

.chart-title{ font-weight:700; font-size:14px; color:#444; }
.chart-xlabel{ font-size:13px; color:var(--muted); text-align:center; margin-top:6px; }
.chart-ylabel{ font-size:13px; color:var(--muted); margin-top:4px; }

.tooltip{ font-size:13px; }
.tooltip-title{ font-weight:700; font-size:14px; margin-bottom:6px; }

.nav-right{ display:flex; gap:10px; }
.nav-btn{
    border:1px solid var(--border);
    background:#fff;
    border-radius:12px;
    padding:6px 10px;
    cursor:pointer;
}
.nav-btn:hover{ background:#f6f6fa; }

.page{ max-width:2200px; margin:0 auto; padding:24px 16px 40px; }
.hero h1{ margin:0; font-size:22px; }
.subtitle{ margin:6px 0 0; color:var(--muted); font-size:14px; }
.small{ margin:8px 0 0; color:var(--muted); font-size:11px; }
code{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }

.error{
    margin-top:12px;
    padding:12px;
    border:1px solid #f3b4b4;
    background:#fff1f1;
    color:#8a1f1f;
    border-radius:14px;
    font-size:13px;
}
.hidden{ display:none; }

/* Matrix */
#matrix{
    width:100%;
    height:100%;
    display:block;
}

.matrix-label{
    font-size: 12px;
    fill: #111;
    opacity: 0.85;
}

.matrix-label.muted{
    opacity: 0.25;
}

.matrix-cell{
    cursor: pointer;
    shape-rendering: crispEdges;
}

.matrix-cell.muted{
    opacity: 0.10;
}

.matrix-cell.active{
    stroke: #111;
    stroke-width: 2px;
}

.matrix-gridline{
    stroke: rgba(0,0,0,0.06);
    shape-rendering: crispEdges;
}

/* Keep the main app within the viewport so the network always fits on screen */
.page{
    min-height: 0;
}

.viz-wrap{
    min-height: 0;
}

#viz{
    height: 100%;
}


.card{
    margin-top:16px;
    height: calc(100vh - 120px);
    border:1px solid var(--border);
    border-radius:18px;
    background:#fff;
    box-shadow: var(--shadow);
    overflow:hidden;
}

/* ===== Clean controls bar: dropdowns + year slider | divider | search ===== */

.controls{
    display:flex;
    align-items:flex-end;
    gap:24px;
    padding:16px 18px;
    border-bottom:1px solid var(--border);
}

/* Left group: 3 items side-by-side */
.controls-group{
    display:flex;
    align-items:flex-end;
    gap:18px;
    flex: 1 1 auto;           /* allow group to take space */
    min-width: 0;
}

/* Narrow dropdown controls */
.control-narrow{
    width: 180px;             /* tweak to taste */
}

/* Slider control wider than dropdowns */
.control-slider{
    flex: 1 1 520px;          /* take remaining room */
    min-width: 360px;
}

/* Divider line */
.controls-divider{
    width:1px;
    align-self:stretch;
    background: rgba(0,0,0,0.10);
    margin: 0 6px;
}

/* Search block on the right */
.controls-right{
    width: 420px;
    max-width: 100%;
}

/* Ensure inputs fill their containers nicely */
.control select{
    width:100%;
}

#yearSlider{
    width:100%;
    height:30px;
    display:block;
    overflow: visible;
    margin:0;
}

/* ===== Linked nodes table under the line chart ===== */

.linked-wrap{
    margin-top: 8px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    padding: 10px 12px;
}

.linked-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.linked-title{
    font-weight: 700;
    font-size: 14px;
    color: #444;
}

.linked-pager{
    display:flex;
    align-items:center;
    gap: 8px;
}

.linked-page-btn{
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 10px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}
.linked-page-btn:hover{ background:#f6f6fa; }
.linked-page-btn:disabled{
    opacity: 0.35;
    cursor: default;
}

.linked-page-info{
    font-size: 12px;
    color: var(--muted);
    min-width: 110px;
    text-align: center;
}

.linked-table-scroll{
    max-height: 260px;         /* keeps the sidebar tidy */
    overflow: auto;
    border-radius: 12px;
}

.linked-table{
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.linked-table thead th{
    position: sticky;
    top: 0;
    background: #fafafe;
    border-bottom: 1px solid var(--border);
    padding: 8px 8px;
    text-align: left;
    font-weight: 700;
    color: #333;
}

.linked-table tbody td{
    border-bottom: 1px solid rgba(0,0,0,0.06);
    padding: 8px 8px;
    vertical-align: top;
}

.linked-table td.num,
.linked-table th.num{
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.linked-empty{
    color: var(--muted);
    font-size: 12px;
    padding: 10px 0;
}


/* Keep on one row until smaller screens */
@media (max-width: 1100px){
    .controls{
        flex-direction:column;
        align-items:stretch;
    }
    .controls-divider{
        display:none;
    }
    .controls-right{
        width:100%;
    }
    .control-slider{
        min-width: 0;
    }
}
.view-toggle{
    display:flex;
    gap:8px;
    align-items:center;
}

.toggle-btn{
    border:1px solid var(--border);
    background:#fff;
    border-radius:12px;
    padding:8px 10px;
    font-size:14px;
    cursor:pointer;
}
.toggle-btn:hover{ background:#f6f6fa; }
.toggle-btn.is-active{
    border-color: rgba(0,0,0,0.18);
    box-shadow: var(--shadow);
    font-weight:700;
}

/* Matrix should fill the viz area, like the network did */
#matrix{
    width: 100%;
    height: 100%;
    display: block;
}


.hidden{ display:none; }  /* you already have this; keep it */


.ticks{
    position:relative; margin-top:2px;
    font-size:13px; color:var(--muted);
    line-height:1.05;
    height:16px;
    display:flex; justify-content:space-between;
    overflow:visible;
}
.tick-mid{ position:absolute; left:50%; transform:translateX(-50%); top:0; }

.search{ display:flex; gap:8px; margin-top:6px; }
.search input{ flex:1; }
.search button{
    border:1px solid var(--border);
    border-radius:12px;
    padding:8px 12px;
    background:#fff;
    cursor:pointer;
}
.search button:hover{ background:#f6f6fa; }

.layout{
    display:grid;
    grid-template-columns: 1fr minmax(480px, 560px);
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.viz-wrap{
    position:relative;
    min-height:0;
    height:100%;
}
.viz{
    position:relative;
    height:100%;
}
#network{ width:100%; height:100%; display:block; }

.viz-badge{
    position:absolute; top:12px; left:12px; z-index:10;
    padding:10px 12px;
    border-radius:16px;
    border:1px solid var(--border);
    background: rgba(255,255,255,.82);
    box-shadow: var(--shadow);
}
.badge-title{ font-weight:700; font-size:14px; }
.badge-sub{ font-size:14px; color:var(--muted); margin-top:3px; }

.legend{
    position:absolute; bottom:12px; right:12px; z-index:10;
    padding:10px 12px;
    border-radius:16px;
    border:1px solid var(--border);
    background: rgba(255,255,255,.82);
    box-shadow: var(--shadow);
    font-size:11px;
    color:#444;
}
.legend-title{ font-weight:700; font-size:12px; margin-bottom:4px; }
.side{
    border-left:1px solid var(--border);
    padding:14px;
    overflow-y:scroll;
}

.side-title{ font-weight:700; font-size:16px; }
.side-name{ font-weight:700; font-size:18px; margin-top:6px; }

.meta{
    margin-top:10px;
    padding:10px 12px;
    border:1px solid var(--border);
    background:#fafafe;
    border-radius:16px;
    font-size:11px;
    color:#333;
}
.meta-grid{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap:10px;
}
.meta-label{ color:var(--muted); }
.meta-value{ font-weight:700; margin-top:2px; }

.chart-block{ margin-top:14px; }
.chart-title{ font-weight:700; font-size:16px; color:#444; }
.chart{
    width:100%;
    height:150px;
    margin-top:4px;
}

.chart-xlabel{ font-size:14px; color:var(--muted); text-align:center; margin-top:6px; }
.chart-ylabel{ font-size:14px; color:var(--muted); margin-top:4px; }

.clearBtn{
    margin-top:14px;
    border:1px solid var(--border);
    background:#fff;
    border-radius:12px;
    padding:10px 12px;
    cursor:pointer;
}
.clearBtn:hover{ background:#f6f6fa; }

.tooltip{
    position:absolute;
    z-index:20;
    min-width:200px;
    padding:10px 12px;
    border-radius:16px;
    border:1px solid var(--border);
    background:#fff;
    box-shadow: var(--shadow);
    font-size:11px;
    color:#333;
}
.tooltip-title{ font-weight:700; font-size:12px; margin-bottom:6px; }
.tooltip-row{ margin-top:4px; }
.tooltip-close{
    float:right;
    border:none;
    background:transparent;
    cursor:pointer;
    color:#777;
}
.tooltip-close:hover{ color:#111; }

@media (max-width: 1300px){
    .controls{ grid-template-columns: 1fr; }
    .layout{
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }
    .side{
        border-left:none;
        border-top:1px solid var(--border);
        overflow: visible;
    }
    .viz-wrap{
        min-height: 70vh;
    }
    .viz{ height: 70vh; }
}

.download-row{
    margin-top:10px;
    display:flex;
    gap:14px;
    justify-content:flex-end;
}

.download-link{
    border:none;
    background:none;
    padding:0;
    font-size:13px;
    color:#444;
    cursor:pointer;
    text-decoration:underline;
}

.download-link:hover{
    color:#111;
}

#yearSlider{
    overflow: visible;
}



.chart-mode-toggle{
    display:flex;
    gap:8px;
    align-items:center;
    margin-top:10px;
}


/* ===== Sidebar filters (moved from top bar) ===== */
.side-controls{
    border: 1px solid var(--border);
    background: #fff;
    border-radius: 16px;
    padding: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}
.side-controls .controls-title{
    font-size: 16px;
    margin: 0 0 10px 0;
}
.side-controls .control{
    font-size: 16px;
    margin-top: 10px;
}
.side-controls .control span{
    font-size: 16px;
    color: #444;
}
.side-controls #yearSlider{
    margin-top: 6px;
}



/* ===== Ensure network area stays unboxed (no panel styling) ===== */
.viz-wrap, #viz, #network{
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}



/* ===== Line chart y-axis label next to chart (inside panel) ===== */
.chart-block{
  position: relative;
  padding-left: 42px;   /* room for rotated y label */
}

.chart-ylabel{
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center;
  white-space: nowrap;
  pointer-events: none;
}

/* remove any previous chart left margin hacks */
.chart{
  margin-left: 0 !important;
}


/* ===== March 2026 incremental UI fixes ===== */

.controls-title{ font-size:20px; }
.side-title{ font-size:20px; }
.side-name{ font-size:22px; }
.control{ font-size:16px; }
.control span{ font-size:15px; }
.control select, .control input[type="range"], .search input{ font-size:18px; }
.search button{ font-size:17px; }
.badge-title{ font-size:16px; }
.badge-sub{ font-size:15px; }
.legend{ font-size:14px; }
.legend-title{ font-size:16px; }
.legend-subtitle{ font-size:14px; }
.legend-note{ font-size:13px; }
.chart-title{ font-size:18px; }
.chart-xlabel, .chart-ylabel{ font-size:15px; }
.linked-title{ font-size:18px; }
.linked-table{ font-size:15px; }
.linked-page-btn, .download-link, .clearBtn, .small{ font-size:15px; }
.filter-row{
    display:grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap:12px;
    align-items:end;
}

.side-controls .control{
    margin-top:0;
}

.side-controls .control + .control,
.side-controls > .control{
    margin-top:12px;
}

.chart-card{
    padding:10px 12px;
    border:1px solid var(--border);
    background:#fff;
    border-radius:16px;
    box-shadow: var(--shadow);
    overflow:hidden;
}

.chart-block{
    position: relative;
    padding: 14px 16px 12px 64px;
    margin-top: 0;
}

.chart{
    width:100%;
    height:240px;
    margin-top:8px;
}

.chart-ylabel{
    position:absolute;
    left:8px;
    top:52%;
    transform: translateY(-50%) rotate(-90deg);
    transform-origin:center;
    white-space:nowrap;
    pointer-events:none;
}

.legend{
    position:absolute;
    right:12px;
    bottom:12px;
    left:auto;
    z-index:10;
    padding:12px 14px;
    min-width:280px;
}

.network-download-row{
    margin-top:12px;
    justify-content:flex-start;
    flex-direction:column;
    align-items:flex-start;
    gap:8px;
}

.download-link{
    font-size:15px;
}

.linked-wrap{
    padding: 12px 14px;
}

.linked-table thead th,
.linked-table tbody td{
    padding: 10px 10px;
}

@media (max-width: 900px){
    .filter-row{
        grid-template-columns: 1fr;
    }

    .chart-block{
        padding-left: 56px;
    }

    .legend{
        min-width: 240px;
        max-width: calc(100% - 24px);
    }
}


/* ===== March 2026 consistency tweaks ===== */
.section-heading{
    font-size:20px !important;
    font-weight:700;
    line-height:1.25;
    color:#111;
    margin:0;
    padding:0 0 10px 0;
}
.section-heading-spaced{
    margin-top:14px;
}
.side-name{
    font-size:20px;
    font-weight:700;
    line-height:1.25;
    color:#111;
    margin:0;
    padding:0 0 10px 0;
}
.side-controls{
    padding:14px;
}
.linked-wrap{
    padding:14px;
}
.chart-card{
    padding:12px;
}
.chart-header-block{
    padding:0 0 6px 0;
}
.chart-block{
    padding:10px 14px 8px 60px;
    margin-top:0;
}
.chart-download-row{
    padding:10px 0 12px 46px;
    margin-top:4px;
    justify-content:flex-start;
    gap:14px;
}
.chart-download-row .download-link{
    font-size:15px;
}
.legend-note{
    font-weight:600;
    font-size:14px;
    color:#333;
    margin-top:10px;
}
@media (max-width: 900px){
    .chart-block{
        padding-left:46px;
    }
}
.legend-zoom-text{
    margin-top:8px;
    font-size:13px;
    color:var(--muted);
    font-weight:600;
}


/* Tutorial modal — matched to site style */
.tutorial-modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:rgba(255,255,255,.72);
  backdrop-filter:blur(6px);
  z-index:9999;
}

.tutorial-modal.is-closed{
  display:none !important;
}

.tutorial-box{
  position:relative;
  width:min(860px, 100%);
  max-height:min(88vh, 900px);
  overflow:auto;
  border:1px solid var(--border);
  border-radius:18px;
  background:#fff;
  box-shadow:var(--shadow);
  padding:22px 22px 18px;
}

.tutorial-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:18px;
  padding-right:52px;
}

.tutorial-kicker{
  font-size:13px;
  color:var(--muted);
  font-weight:700;
  margin-bottom:6px;
  text-transform:uppercase;
  letter-spacing:.03em;
}

.tutorial-main-title{
  margin:0;
  font-size:26px;
  line-height:1.15;
  color:#111;
}

.tutorial-step-pill{
  border:1px solid var(--border);
  border-radius:999px;
  padding:8px 12px;
  background:#fafafe;
  color:#444;
  font-size:14px;
  font-weight:600;
  white-space:nowrap;
}

.tutorial-close-x{
  position:absolute;
  top:14px;
  right:14px;
  width:38px;
  height:38px;
  border:1px solid var(--border);
  border-radius:12px;
  background:#fff;
  color:#555;
  font-size:22px;
  line-height:1;
  cursor:pointer;
}

.tutorial-close-x:hover{
  background:#f6f6fa;
}

.tutorial-slide.is-hidden{
  display:none !important;
}

.tutorial-slide p{
  margin:0;
  font-size:17px;
  line-height:1.55;
  color:#444;
}

.tutorial-intro-grid{
  display:grid;
  grid-template-columns:minmax(0, 1fr) minmax(320px, 390px);
  gap:18px;
  align-items:start;
}

.tutorial-intro-copy{
  display:grid;
  gap:12px;
}

.tutorial-diagram-card,
.tutorial-card,
.tutorial-step{
  border:1px solid var(--border);
  border-radius:16px;
  background:#fff;
  box-shadow:var(--shadow);
}

.tutorial-diagram-card{
  padding:12px;
  background:#fafafe;
}

.tutorial-diagram{
  width:100%;
  height:auto;
  display:block;
}

.tutorial-card-grid{
  display:grid;
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:14px;
}

.tutorial-card{
  padding:16px 16px 14px;
}

.tutorial-card-title{
  font-size:17px;
  font-weight:700;
  color:#111;
  margin-bottom:8px;
}

.tutorial-card p{
  font-size:15px;
  line-height:1.5;
  color:#444;
}

.tutorial-steps{
  display:grid;
  gap:12px;
}

.tutorial-step{
  display:flex;
  gap:14px;
  align-items:flex-start;
  padding:14px 16px;
}

.tutorial-step-num{
  flex:0 0 auto;
  width:32px;
  height:32px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  background:#111;
  color:#fff;
  font-weight:700;
  font-size:15px;
}

.tutorial-step-title{
  font-size:17px;
  font-weight:700;
  color:#111;
  margin-bottom:4px;
}

.tutorial-step p{
  font-size:15px;
  line-height:1.5;
  color:#444;
}

.tutorial-controls{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  margin-top:20px;
  padding-top:16px;
  border-top:1px solid var(--border);
}

.tutorial-actions{
  display:flex;
  gap:10px;
}

.tutorial-btn{
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px 16px;
  cursor:pointer;
  font-size:15px;
  font-weight:600;
}

.tutorial-btn:hover{
  background:#f6f6fa;
}

.tutorial-btn:disabled{
  opacity:.45;
  cursor:default;
}

.tutorial-btn-secondary,
.tutorial-btn-ghost{
  background:#fff;
  color:#333;
}

.tutorial-btn-primary{
  background:#111;
  color:#fff;
  border-color:#111;
}

.tutorial-btn-primary:hover{
  background:#222;
}

.tutorial-dots{
  display:flex;
  align-items:center;
  gap:8px;
}

.tutorial-dot{
  width:9px;
  height:9px;
  border-radius:999px;
  background:#d8d8e3;
}

.tutorial-dot.is-active{
  background:#111;
}

body.tutorial-open{
  overflow:hidden;
}

@media (max-width: 820px){
  .tutorial-intro-grid{
    grid-template-columns:1fr;
  }

  .tutorial-card-grid{
    grid-template-columns:1fr;
  }

  .tutorial-main-title{
    font-size:24px;
  }
}

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

  .tutorial-box{
    padding:18px 18px 16px;
  }

  .tutorial-header{
    flex-direction:column;
    align-items:flex-start;
    padding-right:46px;
  }

  .tutorial-controls{
    flex-direction:column;
    align-items:stretch;
  }

  .tutorial-actions{
    width:100%;
  }

  .tutorial-actions button,
  #tutorialBack{
    flex:1 1 auto;
  }
}


/* Match slide 1 image footprint to the chronic medication tutorial */
.tutorial-diagram-card{
  display:flex;
  align-items:center;
  justify-content:center;
}

.tutorial-guide-image{
  display:block;
  width:100%;
  max-width:340px;
  height:auto;
  margin:0 auto;
  border-radius:12px;
}


html{scrollbar-gutter:stable both-edges;}
body{overflow-y:scroll;}
body.tutorial-open{overflow:hidden;}

.clearBtn-under-chart{
    margin-top:12px;
    margin-left:46px;
}

.small-under-chart{
    margin-left:46px;
}

@media (max-width: 900px){
    .clearBtn-under-chart,
    .small-under-chart{
        margin-left:46px;
    }
}


.tutorial-checkbox{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:14px;
  color:#444;
}

.tutorial-checkbox input{
  width:16px;
  height:16px;
  accent-color:#111;
}
