/* MARTAR sync — Workspace ↔ Document Vault (martar-sync.js).
   Uses the app's own tokens (style.css) so light and dark themes follow. */

/* ---- Workspace → Results: filed-in-Vault strip ------------------------- */
.ms-sync-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 0 0 14px;
}
.ms-sync-strip[hidden] { display: none; }
.ms-strip-label {
  font-size: calc(11px * var(--ui-font-scale, 1)); font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-muted); margin-right: 2px;
}
.ms-chip {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
  max-width: 100%;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  font: inherit; font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--text);
}
button.ms-chip { cursor: pointer; }
button.ms-chip:hover { border-color: var(--primary); }
.ms-chip-meta { color: var(--text-muted); }
.ms-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint); flex: 0 0 auto;
}
.ms-chip.is-filed .ms-dot { background: var(--success); }

/* ---- File to Vault dialog --------------------------------------------- */
.modal.ms-file-modal { max-width: 860px; height: auto; max-height: 88vh; }
.ms-file-body { padding: 16px 20px; overflow-y: auto; flex: 1 1 auto; }
.ms-file-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px; border-top: 1px solid var(--divider);
}
.ms-file-row {
  display: flex; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}
.ms-file-row:last-child { border-bottom: 0; }
.ms-file-row.is-off .ms-file-main { opacity: .55; }
.ms-file-check { padding-top: 2px; }
.ms-file-main { flex: 1 1 auto; min-width: 0; }
.ms-file-name { font-weight: 600; overflow-wrap: anywhere; }
.ms-file-sub { font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--text-muted); margin: 2px 0 8px; }
.ms-file-fields { display: flex; flex-wrap: wrap; gap: 10px; }
.ms-file-fields label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: calc(11px * var(--ui-font-scale, 1)); color: var(--text-muted);
}
.ms-file-fields select, .ms-file-fields input {
  min-width: 0; max-width: 100%;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: calc(12.5px * var(--ui-font-scale, 1));
}
.ms-file-fields label:first-child select { width: min(340px, 70vw); }
.ms-file-result { font-size: calc(12px * var(--ui-font-scale, 1)); margin-top: 6px; }
.ms-result.ok { color: var(--success); }
.ms-result.warn { color: var(--warning); }
.ms-result.err { color: var(--error); }

/* ---- MARTAR uploads → Upload monthly file ----------------------------- */
.ms-up-fields { margin-bottom: 12px; }
.ms-up-drop {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 84px; padding: 14px; margin-bottom: 12px; cursor: pointer;
  border: 1.5px dashed var(--border); border-radius: var(--radius-md);
  background: var(--surface-2); color: var(--text-muted); font-size: calc(13px * var(--ui-font-scale, 1));
  overflow-wrap: anywhere;
}
.ms-up-drop:hover, .ms-up-drop.drag { border-color: var(--primary); color: var(--text); }
.ms-up-drop.has-file { border-style: solid; color: var(--text); font-weight: 600; }
.ms-up-head { font-size: calc(12.5px * var(--ui-font-scale, 1)); margin: 4px 0 8px; }
.ms-up-list { max-height: 40vh; overflow: auto; }

/* ---- Document Vault → MARTAR uploads ---------------------------------- */
.ms-filters input[type="search"] {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: calc(12.5px * var(--ui-font-scale, 1));
  min-width: 0; width: 220px; max-width: 100%;
}
.ms-expander {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-weight: 600; color: var(--text); text-align: left;
  overflow-wrap: anywhere;
}
.ms-caret {
  width: 0; height: 0; flex: 0 0 auto;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .12s ease;
}
.ms-upload-row.is-open .ms-caret { transform: rotate(90deg); }
.ms-sub { font-size: calc(11px * var(--ui-font-scale, 1)); color: var(--text-muted); margin-top: 2px; }
.ms-actions { white-space: nowrap; }
.ms-actions a.btn { text-decoration: none; }
.ms-actions .btn + .btn, .ms-actions .btn + a, .ms-actions a + .btn { margin-left: 4px; }
.ms-type {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: calc(11px * var(--ui-font-scale, 1)); font-weight: 600;
  background: var(--surface-3); color: var(--text);
}
.ms-type-mar { background: var(--primary-soft); color: var(--primary-hover); }
.ms-type-tar { background: var(--warning-soft); color: var(--warning); }
.ms-patients-row > td { background: var(--surface-2); padding: 10px 16px 14px; }
.ms-patients { overflow-x: auto; }
.ms-patients-table { width: 100%; border-collapse: collapse; font-size: calc(12.5px * var(--ui-font-scale, 1)); }
.ms-patients-table th {
  text-align: left; font-weight: 600; font-size: calc(11px * var(--ui-font-scale, 1)); color: var(--text-muted);
  padding: 6px 8px; border-bottom: 1px solid var(--divider);
}
.ms-patients-table td { padding: 6px 8px; border-bottom: 1px solid var(--divider); }
.ms-mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ms-tag {
  margin-left: 6px; padding: 0 6px; border-radius: 999px; font-size: calc(10.5px * var(--ui-font-scale, 1));
  background: var(--surface-3); color: var(--text-muted);
}
.ms-status { font-size: calc(12px * var(--ui-font-scale, 1)); }
.ms-status-filed, .ms-status-linked { color: var(--success); }
.ms-status-replaced { color: var(--text-muted); }
.ms-status-failed { color: var(--error); }
.ms-muted { color: var(--text-muted); font-size: calc(12px * var(--ui-font-scale, 1)); }

/* ---- Coding / Billing → Patient documents pane ------------------------ */
.ms-docs-btn.is-open {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.ms-docs-pane {
  flex: 0 0 46%; min-width: 0;
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border, #e2e6ee);
  background: var(--surface-2);
}
.ms-docs-pane[hidden] { display: none; }
.ms-docs-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-bottom: 1px solid var(--divider);
}
.ms-docs-tabs { display: flex; gap: 4px; flex-wrap: wrap; min-width: 0; }
.ms-docs-tab {
  padding: 5px 10px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: none; cursor: pointer;
  font: inherit; font-size: calc(12.5px * var(--ui-font-scale, 1)); color: var(--text-muted);
}
.ms-docs-tab:hover { background: var(--surface-3); color: var(--text); }
.ms-docs-tab.is-active {
  background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 600;
}
.ms-docs-meta {
  padding: 6px 12px; font-size: calc(12px * var(--ui-font-scale, 1)); color: var(--text-muted);
  border-bottom: 1px solid var(--divider);
  display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center;
}
.ms-docs-meta:empty { display: none; }
.ms-docs-meta a { color: var(--primary); }
.ms-jumps { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.ms-jump {
  padding: 1px 7px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--primary); background: var(--surface);
  color: var(--primary); font: inherit; font-size: calc(11.5px * var(--ui-font-scale, 1));
}
.ms-jump:hover { background: var(--primary-soft); }
.ms-docs-view { flex: 1 1 auto; min-height: 0; display: flex; }
.ms-docs-frame { border: 0; width: 100%; height: 100%; flex: 1 1 auto; background: #525659; }
.ms-docs-empty {
  margin: auto; padding: 24px; max-width: 420px; text-align: center;
  color: var(--text-muted); font-size: calc(13px * var(--ui-font-scale, 1)); line-height: 1.5;
}
.ms-other-list { list-style: none; margin: 0; padding: 12px 14px; }
.ms-other-list li { padding: 6px 0; border-bottom: 1px solid var(--divider); }
.ms-other-list .ms-muted { display: block; }
.ms-link {
  background: none; border: 0; padding: 0; cursor: pointer;
  color: var(--primary); font: inherit; text-align: left; overflow-wrap: anywhere;
}
.ms-link:hover { text-decoration: underline; }

/* With documents open the entry panel narrows so all three columns fit. */
.ops-record-layout.docs-open { --ops-panel-w: 420px; }

@media (max-width: 1100px) {
  /* Narrow screens: the documents pane covers the record instead. */
  .ms-docs-pane {
    position: absolute; left: 0; top: 0; bottom: 0; z-index: 2;
    width: 100%; flex-basis: auto;
  }
}

/* Dictionaries-style labels ("Site · org_…", "Group › Organization") are long;
   keep the filter bar on one line where the screen allows. */
.ms-filters select { max-width: 300px; }

/* Filed chip: Org ID beside an open button (never nested inside it). */
.ms-chip-open {
  display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: inherit; text-align: left;
}
.ms-chip.is-filed:hover { border-color: var(--primary); }

/* ---- "Monthly files" viewer (Cleansing / Coding / Billing) ---------------- */
.modal.ms-monthly-modal { max-width: 96vw; width: 96vw; height: 92vh; }
.ms-monthly-body { flex: 1 1 auto; min-height: 0; display: flex; }
.ms-monthly-side {
  flex: 0 0 320px; max-width: 40%; overflow-y: auto; padding: 10px;
  border-right: 1px solid var(--divider); background: var(--surface-2);
}
.ms-monthly-item {
  display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left;
  padding: 10px; margin-bottom: 8px; cursor: pointer; font: inherit; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.ms-monthly-item:hover { border-color: var(--primary); }
.ms-monthly-item.is-active { border-color: var(--primary); box-shadow: inset 3px 0 0 var(--primary); }
.ms-monthly-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ms-monthly-name { font-weight: 600; overflow-wrap: anywhere; }
.ms-cov { font-size: calc(11.5px * var(--ui-font-scale, 1)); }
.ms-cov-ok { color: var(--success); }
.ms-cov-warn { color: var(--warning); font-weight: 600; }
.ms-monthly-view { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.ms-monthly-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; border-bottom: 1px solid var(--divider);
}
.ms-monthly-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; overflow-wrap: anywhere; }
.ms-monthly-actions { display: flex; gap: 6px; }
.ms-monthly-actions a.btn { text-decoration: none; }
.ms-monthly-check { padding: 6px 12px 0; }
.ms-monthly-jumps {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
  padding: 6px 12px; max-height: 76px; overflow-y: auto;
}
.ms-jump-warn { border-color: var(--warning); color: var(--warning); }
.ms-monthly-frame { flex: 1 1 auto; min-height: 0; display: flex; border-top: 1px solid var(--divider); }
@media (max-width: 760px) {
  .ms-monthly-body { flex-direction: column; }
  .ms-monthly-side { flex: 0 0 auto; max-width: none; max-height: 34vh; border-right: 0;
                     border-bottom: 1px solid var(--divider); }
}
