:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --text:#0b0f1a;
  --muted:#5b6270;
  --line:#e5e7ef;
  --shadow: 0 10px 30px rgba(15,20,35,0.08);

  --blue:#1f6fff;
  --yellow:#f0c419;
  --orange:#f59e0b;
  --red:#ef4444;

  --railW: minmax(260px, 22vw);
  --radius: 18px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: "Calibri", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

*{ box-sizing:border-box; }
html,body{ height:100%; margin:0; font-family:var(--sans); color:var(--text); background:var(--bg); }

body[data-theme="dark"]{
  background:#0a0f1c;
  --bg:#0a0f1c;
  --card:#131c32;
  --text:#f1f5ff;
  --muted:#d0d9ee;
  --line:#2a3552;
  --shadow: 0 10px 30px rgba(2,6,23,0.45);
}

.app{ height:100%; display:flex; flex-direction:column; }
.topbar{
  position:sticky; top:0; z-index:1000;
  display:flex; align-items:center; justify-content:flex-start;
  padding:14px 18px;
  height:72px;
  flex-shrink:0;
  border-bottom:1px solid var(--line);
  background:rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
}
body[data-theme="dark"] .topbar{
  background:rgba(10,15,28,0.94);
}

.brand{ display:flex; gap:12px; align-items:center; }
.logo{
  width:42px; height:42px; border-radius:14px;
  display:grid; place-items:center;
  background:linear-gradient(180deg, #1f6fff, #0b4bd6);
  color:white; font-weight:700;
  box-shadow: 0 8px 18px rgba(31,111,255,0.22);
}
.title{ font-weight:700; font-size:16px; }
.subtitle{ font-size:12px; color:var(--muted); margin-top:2px; }

.segmented{
  display:flex; gap:6px; padding:6px; border-radius:999px;
  background:#eef1f8;
  border:1px solid #e4e8f3;
}
.topbar .segmented{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
}
body[data-theme="dark"] .segmented{
  background:#141c30;
  border-color:#2a3552;
}
.seg{
  display:inline-flex; align-items:center; justify-content:center;
  min-height:32px;
  border:0; background:transparent; padding:9px 14px;
  border-radius:999px; cursor:pointer; font-weight:600; font-size:13px;
  color:#2b3447;
  text-decoration:none;
}
.seg:visited{ color:inherit; }
body[data-theme="dark"] .seg{ color:#cbd5f5; }
.seg.active{ background:white; box-shadow: 0 6px 16px rgba(15,20,35,0.08); }
body[data-theme="dark"] .seg.active{
  background:#18223c;
  box-shadow: 0 0 0 1px rgba(120,136,255,0.25);
}
body[data-theme="dark"] .seg.active{
  color:#f8fbff;
}
.seg.disabled{ opacity:0.45; cursor:not-allowed; }

.status{ display:flex; gap:8px; align-items:center; margin-left:auto; }
.pill{
  padding:6px 10px; border-radius:999px;
  font-size:12px; border:1px solid var(--line);
  background:white; color:var(--muted);
}
body[data-theme="dark"] .pill{
  background:#111a2e;
  color:#e6edff;
  border-color:#2a3552;
}
.rail-toggle{
  cursor:pointer;
  border-color: rgba(31,111,255,0.25);
  color:#1146c2;
  background: rgba(31,111,255,0.08);
}
.rail-toggle:hover{
  background: rgba(31,111,255,0.16);
}
.pill-blue{ border-color: rgba(31,111,255,0.35); color:#1146c2; background:rgba(31,111,255,0.08); }
.pill-action{
  padding:8px 12px; border-radius:12px; border:1px solid rgba(31,111,255,0.35);
  background:rgba(31,111,255,0.10); color:#1146c2; font-weight:700; cursor:pointer;
}
body[data-theme="dark"] .pill-action{
  color:#d6ddff;
  border-color: rgba(120,136,255,0.7);
  background:rgba(120,136,255,0.22);
}
body[data-theme="dark"] .pill-action.active{
  background:rgba(120,136,255,0.35);
  box-shadow: 0 0 0 2px rgba(120,136,255,0.35), 0 10px 22px rgba(5,12,30,0.45);
}
body[data-theme="dark"] .pill-action.fed-active{
  background:rgba(99,210,255,0.35);
  border-color: rgba(99,210,255,0.7);
  color:#e6fbff;
  box-shadow: 0 0 0 2px rgba(99,210,255,0.35), 0 10px 22px rgba(5,12,30,0.45);
}
.pill-action:hover{ background:rgba(31,111,255,0.16); }
.pill-action.active{ background:rgba(31,111,255,0.22); }

.layout{
  flex:1; display:grid;
  grid-template-columns: minmax(0, 1fr) var(--railW);
  gap:14px;
  padding:14px;
}
body[data-theme="dark"] .layout{
  background:#0a0f1c;
}
.atlas-layout .rail.left{ display:none; }
.rail{
  transition: opacity 160ms ease;
}
.rail-collapsed .layout{
  grid-template-columns: minmax(0, 1fr);
}
.rail-collapsed .rail{
  display:none;
}

.rail .panel{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow: var(--shadow);
  padding:14px;
}
.panel-title{ font-weight:700; font-size:12px; color:#2b3447; letter-spacing:0.06em; text-transform:uppercase; }

.field{ display:flex; flex-direction:column; gap:6px; margin-top:12px; font-size:12px; color:var(--muted); }
.cohortPanel .field{
  margin-top:0;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fbfcff;
  box-shadow: 0 6px 12px rgba(15,20,35,0.04);
}
body[data-theme="dark"] .cohortPanel .field{ background:#203055; border-color:#334061; }
body[data-theme="dark"] .cohortPanel{ background:#182443; }
.cohortPanel .field label{
  font-weight:700;
  color:#2b3447;
  font-size:12px;
}
body[data-theme="dark"] .cohortPanel .field label{
  color:#e6edff;
}
select{
  padding:10px 10px;
  border-radius:12px; border:1px solid var(--line);
  background:white; outline:none; font-size:13px;
}
body[data-theme="dark"] select{
  background:#203055;
  color:#f1f5ff;
  border-color:#334061;
}
body[data-theme="dark"] select::placeholder,
body[data-theme="dark"] input::placeholder{
  color:#b9c6e5;
}
.btn{
  width:100%; margin-top:14px; padding:12px;
  border-radius:14px; border:1px solid var(--line);
  background:white; cursor:pointer; font-weight:700;
}
.btn[disabled], .btn.disabled{
  opacity:0.55; cursor:not-allowed; box-shadow:none;
}
body[data-theme="dark"] .btn{
  background:#1f2f52;
  color:#f3f6ff;
  border-color:#3a4a72;
  box-shadow: 0 8px 18px rgba(7,12,28,0.35);
}
body[data-theme="dark"] .btn:hover{
  background:#243760;
  border-color:#445580;
}
.btn.primary{
  border-color: rgba(31,111,255,0.35);
  background: rgba(31,111,255,0.10);
  color:#1146c2;
}
body[data-theme="dark"] .btn.primary{
  background: linear-gradient(180deg, #3b7bff 0%, #1f5fff 100%);
  border-color:#5d8bff;
  color:#f8fbff;
  box-shadow: 0 10px 24px rgba(15,35,90,0.45);
}
.divider{ height:1px; background:var(--line); margin:14px 0; }
.hint{ font-size:12px; color:var(--muted); line-height:1.45; margin-top:10px; }
.toggle{ display:flex; align-items:center; gap:6px; font-size:12px; }

.canvasWrap{ display:flex; flex-direction:column; gap:10px; }
.canvasHeader{
  display:flex; align-items:flex-end; justify-content:space-between;
  padding:4px 4px 0 4px;
}
.canvasTitle{ font-weight:800; font-size:18px; }
.canvasMeta{ font-size:12px; color:var(--muted); }

.canvasCard{
  position:relative;
  flex:1;
  min-height:520px;
  background: linear-gradient(180deg, #f8fafc 0%, #fdfcfb 100%);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}
body[data-theme="dark"] .canvasCard{
  background: radial-gradient(120% 120% at 10% 0%, #111a2e 0%, #0a0f1c 60%);
}
.mode-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.analyticsGrid{
  display:grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  gap:14px;
}
.patient-review-grid{
  display:grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap:14px;
}
.patient-search{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:12px;
  box-shadow: 0 6px 16px rgba(15,20,35,0.06);
}
.search-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:8px;
}
.search-grid input{
  padding:10px 10px;
  border-radius:12px;
  border:1px solid var(--line);
  font-size:13px;
}
.list-box{
  border:1px solid var(--line);
  border-radius:12px;
  background:#fbfcff;
  padding:8px;
  min-height:120px;
  max-height:220px;
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:6px;
}
body[data-theme="dark"] .list-box{
  background:#1b2746;
  border-color:#2a3552;
}
.list-item{
  border:1px solid transparent;
  border-radius:10px;
  padding:8px 10px;
  font-size:12px;
  cursor:pointer;
}
.list-item:hover{
  background:rgba(31,111,255,0.08);
}
.list-item.selected{
  border-color: rgba(31,111,255,0.6);
  background:rgba(31,111,255,0.12);
}
.patient-note{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  box-shadow: 0 6px 16px rgba(15,20,35,0.06);
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height:420px;
}
.gray-zone{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  background:#f8f9ff;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.gray-toggle{
  font-size:12px;
  color:var(--muted);
  display:flex;
  gap:8px;
  align-items:center;
}
.gray-editor textarea{
  width:100%;
  border-radius:10px;
  border:1px solid var(--line);
  padding:8px 10px;
  font-size:12px;
  background:#ffffff;
}
.gray-list{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.gray-item{
  border:1px solid var(--line);
  border-radius:10px;
  padding:8px 10px;
  background:#ffffff;
  font-size:12px;
}
.gray-item .gray-meta{
  font-size:11px;
  color:var(--muted);
  margin-bottom:4px;
}
.note-meta{
  font-size:12px;
  color:var(--muted);
}
.note-body{
  background:#ffffff;
  color:#111827;
  border-radius:12px;
  padding:12px;
  font-size:12px;
  line-height:1.4;
  min-height:360px;
  overflow:auto;
  white-space:pre-wrap;
  margin:0;
}
.note-actions{
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:8px;
}
.inline-hint{
  font-size:11px;
  color:var(--muted);
  opacity:0;
  transition:opacity 0.15s ease;
}
.note-actions:hover .inline-hint{
  opacity:1;
}
.addendum-editor{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  background:#f6f8ff;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.addendum-editor textarea,
.addendum-editor select{
  width:100%;
  border-radius:10px;
  border:1px solid var(--line);
  padding:8px 10px;
  font-size:12px;
  background:#ffffff;
}
.addendum-editor textarea{
  resize:vertical;
}
.inline-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
}
.addendum-list{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.collapse-panel{
  border:1px solid var(--line);
  border-radius:12px;
  padding:8px 10px;
  background:#ffffff;
}
.collapse-panel summary{
  cursor:pointer;
  font-weight:700;
  font-size:12px;
  color:#1f2937;
  list-style:none;
}
.collapse-panel summary::-webkit-details-marker{
  display:none;
}
.collapse-panel[open]{
  box-shadow: inset 0 0 0 1px rgba(31,111,255,0.08);
}
.collapse-panel .tags-grid{
  margin-top:8px;
}
.collapse-panel .addendum-list{
  margin-top:8px;
}
.addendum-item{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  background:#ffffff;
}
.addendum-header{
  display:flex;
  justify-content:space-between;
  font-size:11px;
  color:var(--muted);
  margin-bottom:6px;
}
.addendum-body{
  font-size:12px;
  white-space:pre-wrap;
  margin:0;
}
.addendum-badge{
  font-weight:700;
  font-size:10px;
  text-transform:uppercase;
  letter-spacing:0.04em;
  color:#1f3a8a;
}
.tags-grid{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.tags-group{
  border:1px solid var(--line);
  border-radius:12px;
  padding:8px;
  background:#fbfcff;
}
body[data-theme="dark"] .tags-group{
  background:#1b2746;
  border-color:#2a3552;
}
.tags-group-title{
  font-weight:700;
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:0.04em;
  color:#2b3447;
  margin-bottom:6px;
}
.tag-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 8px;
  border-radius:999px;
  border:1px solid rgba(31,111,255,0.25);
  background:rgba(31,111,255,0.08);
  font-size:11px;
  margin:2px 4px 0 0;
  color:#1f3a8a;
}
.tag-chip.tag-stale{
  color:rgba(31,58,138,0.45);
  border-color:rgba(31,111,255,0.2);
  background:rgba(31,111,255,0.04);
  text-decoration:line-through;
}

.grayzone-grid{
  display:grid;
  grid-template-columns: 0.9fr 1.1fr 1.2fr;
  gap:16px;
}
.grayzone-search,
.grayzone-list,
.grayzone-detail{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:12px;
}
.grayzone-detail .gray-detail-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  max-height:260px;
  overflow:auto;
}
.grayzone-list .list-item{
  cursor:pointer;
}

.case-logs-controls{
  display:block;
  margin-bottom:14px;
  background:#f6f8fc;
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px;
}
.case-logs-layout{
  display:grid;
  grid-template-columns: minmax(520px, 1fr) 240px;
  gap:16px;
  align-items:start;
}
.case-logs-main{
  min-width:0;
}
.case-logs-side{
  position:sticky;
  top:96px;
}
.case-logs-filters{
  display:grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap:12px;
}
.case-logs-filters .field:first-child{
  grid-column: 1 / -1;
}
.case-logs-controls .field{
  min-width:160px;
}
.case-logs-actions{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.case-logs-actions .btn{
  margin-top:0;
}
.segmented.small .seg{
  padding:6px 10px;
  font-size:11px;
}
.segmented .seg.disabled{
  opacity:0.5;
  pointer-events:none;
}
.case-logs-filters .segmented{
  width:100%;
  justify-content:space-between;
}
.case-logs-filters .segmented .seg{
  flex:1;
  text-align:center;
}
.favorite-list{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:8px;
}
.favorite-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:6px;
  padding:6px 8px;
  border:1px solid var(--line);
  border-radius:10px;
  background:#fff;
  font-size:12px;
}
.favorite-item button{
  border:0;
  background:transparent;
  color:#8a94a6;
  cursor:pointer;
}
.helper-row{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:8px;
}
.helper-metric{
  background:#f6f8fc;
  border:1px solid var(--line);
  border-radius:10px;
  padding:8px;
  display:flex;
  flex-direction:column;
  gap:4px;
}
.helper-metric .label{
  font-size:11px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:0.04em;
}
.helper-metric .value{
  font-weight:700;
  font-size:14px;
  color:#1f2a44;
}
.helper-metric input{
  width:100%;
  border:1px solid var(--line);
  border-radius:8px;
  padding:4px 6px;
  font-size:12px;
  background:#fff;
}
.helper-patient{
  margin-top:10px;
  padding:8px;
  border:1px dashed var(--line);
  border-radius:10px;
  background:#fbfcff;
  font-size:12px;
}
.history-list{
  display:flex;
  flex-direction:column;
  gap:8px;
  margin-top:8px;
  font-size:12px;
}
.history-item{
  border:1px solid var(--line);
  border-radius:10px;
  padding:8px;
  background:#fff;
}
.history-item .meta{
  font-size:11px;
  color:var(--muted);
  margin-bottom:6px;
}
@media (max-width: 1200px){
  .case-logs-layout{
    grid-template-columns: 1fr;
  }
  .case-logs-side{
    position:static;
  }
  .case-logs-filters{
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
  .case-logs-actions{
    flex-direction:row;
    flex-wrap:wrap;
  }
  .case-logs-actions .btn{
    width:auto;
    min-width:180px;
  }
}
.case-logs-grid{
  border:1px solid var(--line);
  border-radius:14px;
  background:linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,250,255,0.98));
  padding:10px;
  min-height:calc(100vh - 320px);
}
.case-logs-table{
  overflow:auto;
  max-height:520px;
  border-radius:10px;
  border:1px solid var(--line);
  background:#fff;
}
.case-logs-table .tabulator{
  border:0;
  font-size:13px;
}
.case-logs-table .tabulator .tabulator-header{
  background:linear-gradient(180deg, #f2f4f8 0%, #e9eef7 100%);
  border-bottom:1px solid var(--line);
  box-shadow:0 2px 8px rgba(15,20,35,0.08);
  z-index:2;
  position:relative;
}
.case-logs-table .tabulator .tabulator-header .tabulator-col{
  background:transparent;
  border-right:1px solid var(--line);
  font-weight:700;
  color:#1f2a44;
}
.case-logs-table .tabulator .tabulator-col-group{
  background:linear-gradient(180deg, #eef1f6 0%, #e3e8f3 100%);
  border-right:1px solid var(--line);
  border-bottom:1px solid var(--line);
  font-weight:700;
  color:#1f2a44;
  position:sticky;
  top:0;
  z-index:3;
  background-clip:padding-box;
}
.case-logs-table .tabulator .tabulator-header .tabulator-col:last-child{
  border-right:0;
}
.case-logs-table .tabulator .tabulator-row{
  border-bottom:1px solid var(--line);
  background:#fff;
}
.case-logs-table .tabulator .tabulator-row:nth-child(even){
  background:#fbfcff;
}
.case-logs-table .tabulator .tabulator-row:hover{
  background:#f3f7ff;
}
.case-logs-table .tabulator .tabulator-cell{
  border-right:1px solid var(--line);
  padding:8px 10px;
}
.case-logs-table .tabulator .tabulator-row{
  min-height:36px;
}
.case-logs-table .tabulator .tabulator-col-title{
  white-space:normal;
  line-height:1.2;
}
.case-logs-table .tabulator .tabulator-cell.cell-wrap{
  white-space:normal;
}
.case-logs-table .tabulator .tabulator-cell:last-child{
  border-right:0;
}
.case-logs-table .tabulator .tabulator-cell.tabulator-editing{
  outline:2px solid rgba(31,111,255,0.6);
  outline-offset:-2px;
  background:#f5f9ff;
}
.case-logs-table .tabulator .tabulator-col.row-index,
.case-logs-table .tabulator .tabulator-cell.row-index{
  background:#f6f8fc;
  text-align:center;
  font-weight:600;
  color:#5d6b8a;
}
.cohortPanel{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:12px;
  box-shadow: 0 6px 16px rgba(15,20,35,0.06);
}
.cohortPanel .scope-row{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.cardsPanel{
  display:flex;
  flex-direction:column;
  gap:12px;
}
.cardRow{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap:12px;
}
.metric-card{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.card-title{
  font-weight:700;
  font-size:13px;
  letter-spacing:0.02em;
  color:#1f2a44;
}
.metric-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap:8px;
}
.metric-tile{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
  background:#fbfcff;
  font-size:12px;
}
body[data-theme="dark"] .metric-tile{
  background:#203055;
  border-color:#334061;
}
body[data-theme="dark"] .card{
  background:#1c2a4e;
  border-color:#334061;
}
body[data-theme="dark"] .card-title{
  color:#e6edff;
}
body[data-theme="dark"] .ranked li{
  color:#e6edff;
  border-bottom-color: rgba(230,237,255,0.08);
}
body[data-theme="dark"] .metric-tile .value{
  color:#f8fbff;
}
.metric-tile .value{
  font-size:18px;
  font-weight:800;
  color:#0b0f1a;
}
.ranked{
  list-style:none;
  padding:0;
  margin:0;
  display:flex;
  flex-direction:column;
  gap:6px;
}
.ranked li{
  display:flex;
  justify-content:space-between;
  align-items:center;
  border-bottom:1px dashed rgba(15,23,42,0.08);
  padding-bottom:6px;
  font-size:13px;
  gap:10px;
}
.ranked li .label{
  flex:1;
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.ranked li:last-child{ border-bottom:none; padding-bottom:0; }
.ranked .count{
  color:var(--blue);
  font-weight:700;
}
.dual-list{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}
.filter-row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:8px;
  align-items:center;
}
.filter-row .btn{
  grid-column: 1 / -1;
}
.filter-row input{
  padding:10px 10px;
  border-radius:12px;
  border:1px solid var(--line);
  font-size:13px;
}
body[data-theme="dark"] .filter-row input{
  background:#203055;
  color:#f1f5ff;
  border-color:#334061;
}
.filter-row select,
.filter-row input{
  width:100%;
}
.range-row{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:8px;
}
.range-row input{
  padding:10px 10px;
  border-radius:12px;
  border:1px solid var(--line);
  font-size:13px;
  width:100%;
}
body[data-theme="dark"] .range-row input{
  background:#203055;
  color:#f1f5ff;
  border-color:#334061;
}
.chip-row{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(31,111,255,0.3);
  background:rgba(31,111,255,0.12);
  font-size:12px;
  color:#1146c2;
}
.chip button{
  border:0;
  background:transparent;
  cursor:pointer;
  font-size:12px;
  color:#1146c2;
}
.compare-box{
  border:1px dashed var(--line);
  border-radius:12px;
  padding:12px;
  font-size:13px;
  color:var(--muted);
}
.empty{
  position:absolute; inset:0; display:grid; place-items:center;
  font-size:13px; color:var(--muted);
}
.hidden{ display:none; }

#atlas{
  display:flex;
  flex-direction:column;
  gap:14px;
}
.atlas-summary .card-row{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
  gap:12px;
}
.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px 14px;
  box-shadow: 0 8px 20px rgba(15,20,35,0.06);
}
.card.stat .label{ font-size:12px; color:var(--muted); margin-bottom:6px; }
.card.stat .value{ font-size:20px; font-weight:800; color:var(--text); }
.atlas-concepts{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap:12px;
}
.concept-card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px 14px;
  box-shadow: 0 8px 20px rgba(15,20,35,0.06);
  min-height:180px;
}
.concept-title{ font-weight:700; color:var(--text); margin-bottom:8px; }
.concept-card ul{ list-style:none; padding:0; margin:0; }
.concept-card li{
  display:flex; justify-content:space-between; align-items:center;
  padding:4px 0;
  font-size:13px; color:var(--text);
  border-bottom:1px dashed rgba(15,23,42,0.07);
}
.concept-card li:last-child{ border-bottom:none; }
.concept-card .lbl{
  max-width:140px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.concept-card .ct{
  font-weight:700;
  color:var(--blue);
  padding-left:8px;
}
.concept-item{
  cursor:pointer;
}
.concept-item:hover{
  background:rgba(31,111,255,0.05);
}
.sparkline{
  margin-top:8px;
  padding:6px 8px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fbfcff;
}
body[data-theme="dark"] .sparkline{
  background:#203055;
  border-color:#334061;
}
.sparkline svg{
  width:100%;
  height:48px;
  display:block;
}
.sparkline .sparkline-line{
  fill:none;
  stroke:#1f6fff;
  stroke-width:2;
}
.sparkline .sparkline-fill{
  fill:rgba(31,111,255,0.12);
  stroke:none;
}

.vault-list{
  margin-top:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
  max-height:380px;
  overflow:auto;
  padding-right:4px;
}
.vault-item{
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px 12px;
  background:#fbfcff;
  box-shadow: 0 6px 14px rgba(15,20,35,0.06);
  font-size:12px;
}
body[data-theme="dark"] .vault-item{ background:#203055; border-color:#334061; }
.vault-item.selected{
  border-color: rgba(31,111,255,0.6);
  box-shadow: 0 10px 22px rgba(31,111,255,0.12);
}
.vault-title{
  font-weight:700;
  color:var(--text);
  display:flex;
  justify-content:space-between;
  gap:8px;
}
.vault-link{
  color:inherit;
  text-decoration:none;
  font-weight:700;
}
.vault-link:hover{
  text-decoration:underline;
}
.vault-meta{
  margin-top:6px;
  color:var(--muted);
  font-size:11px;
  word-break:break-word;
}
.muted{
  color:var(--muted);
}

.inspector{ margin-top:10px; }
.kv{ display:flex; justify-content:space-between; padding:8px 0; font-size:13px; }
.tags{ display:flex; flex-wrap:wrap; gap:8px; margin-top:10px; }
.tag{
  padding:6px 10px; border-radius:999px;
  border:1px solid var(--line);
  background:#fbfcff;
  font-size:12px; color:#2b3447;
}
body[data-theme="dark"] .tag{
  background:#203055;
  color:#e6edff;
  border-color:#334061;
}
body[data-theme="dark"] .hint{
  color:#d6def3;
}
body[data-theme="dark"] .panel-title{
  color:#cdd6f4;
}
#bucketRow{
  display:flex; gap:8px; flex-wrap:wrap;
}
.bucket{
  border:1px solid #e4e8f3;
  background:#f7f9ff;
  border-radius:12px;
  padding:8px 12px;
  font-weight:600;
  cursor:pointer;
}
body[data-theme="dark"] .bucket{
  border-color:#2a3552;
  background:#1b2746;
  color:#e6edff;
}
.bucket.active{
  background:white;
  box-shadow: 0 6px 16px rgba(15,20,35,0.08);
  border-color: rgba(31,111,255,0.35);
  color:#1146c2;
}
body[data-theme="dark"] .bucket.active{
  background:#18223c;
  color:#e6edff;
  box-shadow: 0 0 0 1px rgba(120,136,255,0.25);
}

/* THEME: studio dark overrides */
body[data-theme="dark"] .gray-zone,
body[data-theme="dark"] .grayzone-search,
body[data-theme="dark"] .grayzone-list,
body[data-theme="dark"] .grayzone-detail,
body[data-theme="dark"] .addendum-editor,
body[data-theme="dark"] .collapse-panel,
body[data-theme="dark"] .addendum-item,
body[data-theme="dark"] .tags-group,
body[data-theme="dark"] .favorite-item,
body[data-theme="dark"] .helper-metric,
body[data-theme="dark"] .history-item,
body[data-theme="dark"] .helper-patient{
  background:#1b2746;
  border-color:#2a3552;
  color:var(--text);
}

body[data-theme="dark"] .gray-editor textarea,
body[data-theme="dark"] .grayzone-detail textarea,
body[data-theme="dark"] .addendum-editor textarea,
body[data-theme="dark"] .addendum-editor select,
body[data-theme="dark"] .helper-metric input,
body[data-theme="dark"] .search-grid input,
body[data-theme="dark"] .case-logs-controls input{
  background:#1b2746;
  border-color:#2a3552;
  color:#e6edff;
}

body[data-theme="dark"] .gray-editor textarea::placeholder,
body[data-theme="dark"] .grayzone-detail textarea::placeholder,
body[data-theme="dark"] .addendum-editor textarea::placeholder,
body[data-theme="dark"] .search-grid input::placeholder,
body[data-theme="dark"] .case-logs-controls input::placeholder{
  color:#9fb0d6;
}

body[data-theme="dark"] .note-body{
  background:#111a2e;
  color:#e6edff;
}

body[data-theme="dark"] .case-logs-controls{
  background:#111a2e;
  border-color:#2a3552;
}

body[data-theme="dark"] .case-logs-grid{
  background:linear-gradient(180deg, rgba(17,26,46,0.96), rgba(10,15,28,0.98));
  border-color:#2a3552;
}

body[data-theme="dark"] .case-logs-table{
  background:#0f172a;
  border-color:#2a3552;
}

body[data-theme="dark"] .case-logs-table .tabulator{
  color:#e6edff;
}

body[data-theme="dark"] .case-logs-table .tabulator .tabulator-header{
  background:linear-gradient(180deg, #1a2740 0%, #16223a 100%);
  border-bottom:1px solid #2a3552;
  box-shadow:0 2px 10px rgba(2,6,23,0.6);
}

body[data-theme="dark"] .case-logs-table .tabulator .tabulator-header .tabulator-col{
  border-right:1px solid #2a3552;
  color:#e6edff;
}

body[data-theme="dark"] .case-logs-table .tabulator .tabulator-col-group{
  background:linear-gradient(180deg, #1f2d4a 0%, #17243d 100%);
  border-right:1px solid #2a3552;
  border-bottom:1px solid #2a3552;
  color:#e6edff;
}

body[data-theme="dark"] .case-logs-table .tabulator .tabulator-row{
  background:#101a2f;
  border-bottom:1px solid #2a3552;
}

body[data-theme="dark"] .case-logs-table .tabulator .tabulator-row:nth-child(even){
  background:#0c1628;
}

body[data-theme="dark"] .case-logs-table .tabulator .tabulator-row:hover{
  background:#1a2742;
}

body[data-theme="dark"] .case-logs-table .tabulator .tabulator-cell{
  border-right:1px solid #2a3552;
  color:#e6edff;
}

body[data-theme="dark"] .case-logs-table .tabulator .tabulator-col.row-index,
body[data-theme="dark"] .case-logs-table .tabulator .tabulator-cell.row-index{
  background:#121a2e;
  color:#b8c2dd;
}

body[data-theme="dark"] .case-logs-table .tabulator .tabulator-cell.tabulator-editing{
  outline-color:rgba(120,136,255,0.7);
  background:#1a2742;
}


body[data-theme="dark"] .app-root,
body[data-theme="dark"] .shell-page{
  background:#0a0f1c;
}

body[data-theme="light"] .app-root,
body[data-theme="light"] .shell-page{
  background:#f6f7fb;
}

html[data-theme="dark"],
html[data-theme="dark"] body{
  background:#0a0f1c;
}

html[data-theme="light"],
html[data-theme="light"] body{
  background:#f6f7fb;
}

.layout.no-rail{
  grid-template-columns: 1fr;
}

.layout.no-rail .rail{
  display:none;
}


.rail-toggle-row{
  display:grid;
  grid-template-columns: minmax(0, 1fr) var(--railW);
  gap:14px;
  padding:0 14px 8px;
}

.rail-toggle-row .rail-toggle{
  grid-column:2;
  justify-self:end;
}

.rail-collapsed .rail-toggle-row{
  grid-template-columns: 1fr;
}

.rail-collapsed .rail-toggle-row .rail-toggle{
  grid-column:1;
}
