    :root {
      --bg: #faf9f7;
      --bg-deep: #f0eeeb;
      --surface: #ffffff;
      --surface-hover: #f5f3f0;
      --border: #d5cfc5;
      --border-light: #bfb8ad;
      --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
      --text: #1e293b;
      --text-muted: #556270;
      --text-dim: #8c9aab;
      --accent: #0d9488;
      --accent-light: #14b8a6;
      --accent-glow: rgba(13, 148, 136, 0.10);
      --purple: #7c3aed;
      --purple-light: #8b5cf6;
      --warm: #d97706;
      --green: #22c55e;
      --amber: #f59e0b;
      --red: #ef4444;
    }
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
      background: var(--bg);
      color: var(--text);
      line-height: 1.5;
      min-height: 100vh;
    }
    .container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }

    /* Header — two-row layout */
    header {
      padding: 0.5rem 1rem;
      border-bottom: 1px solid var(--border);
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 0.5rem 1rem;
      position: sticky;
      top: 0;
      background: rgba(250, 249, 247, 0.85);
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
      z-index: 50;
      margin: 0 -1rem;
    }
    .header-top {
      display: flex;
      align-items: center;
      gap: 0.75rem;
      width: 100%;
    }
    .header-top .logo { flex-shrink: 0; }
    .header-top .patient-controls { flex: 1; min-width: 0; }
    .header-top .header-account { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; margin-left: auto; }
    .logo {
      font-family: 'DM Serif Display', Georgia, serif;
      font-size: 1.25rem;
      letter-spacing: -0.01em;
    }
    .logo span { color: var(--accent); }
    .header-right { display: flex; align-items: center; gap: 0.75rem; width: 100%; justify-content: flex-end; padding-top: 0.125rem; }
    .version { font-size: 0.75rem; color: var(--text-muted); }
    .refresh-btn {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text);
      padding: 0.375rem 0.75rem;
      border-radius: 0.375rem;
      cursor: pointer;
      font-size: 0.8125rem;
    }
    .refresh-btn:hover { border-color: var(--accent); color: var(--accent); }

    /* Patient selector */
    .patient-controls { display: flex; align-items: center; gap: 0.5rem; }
    .patient-select {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text);
      padding: 0.375rem 0.75rem;
      border-radius: 0.375rem;
      font-size: 0.8125rem;
      font-family: inherit;
      cursor: pointer;
      min-width: 10rem;
    }
    .patient-select:hover { border-color: var(--accent); }
    .patient-select:focus { outline: none; border-color: var(--accent); }
    .add-patient-btn {
      background: var(--accent);
      border: none;
      color: #fff;
      padding: 0.375rem 0.75rem;
      border-radius: 0.375rem;
      cursor: pointer;
      font-size: 0.8125rem;
      font-weight: 600;
      white-space: nowrap;
    }
    .add-patient-btn:hover { background: var(--accent-light); }
    .archive-patient-btn {
      background: none;
      border: 1px solid var(--border);
      color: var(--text-muted);
      padding: 0.375rem 0.75rem;
      border-radius: 0.375rem;
      cursor: pointer;
      font-size: 0.75rem;
      white-space: nowrap;
    }
    .archive-patient-btn:hover { border-color: var(--red, #e74c3c); color: var(--red, #e74c3c); }
    .archive-patient-btn.restore { border-color: var(--green, #27ae60); color: var(--green, #27ae60); }

    /* Segmented language switcher */
    .lang-switcher { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
    .lang-switcher button { background: none; border: none; color: var(--text-muted); padding: 0.2rem 0.45rem; cursor: pointer; font-size: 0.6875rem; font-family: inherit; line-height: 1; transition: background 0.15s, color 0.15s; }
    .lang-switcher button.lang-active { background: var(--accent); color: #fff; font-weight: 600; }
    .lang-switcher button:not(.lang-active):hover { color: var(--accent); }
    .lang-switcher button:first-child { border-right: 1px solid var(--border); }

    /* Onboarding wizard modal */
    .wizard-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 100;
      background: rgba(0, 0, 0, 0.4);
      backdrop-filter: blur(4px);
      align-items: center;
      justify-content: center;
    }
    .wizard-overlay.active { display: flex; }
    .wizard-panel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 0.75rem;
      padding: 2rem;
      width: 100%;
      max-width: 32rem;
      max-height: 90vh;
      overflow-y: auto;
      box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    }
    .wizard-panel h2 {
      font-family: 'DM Serif Display', Georgia, serif;
      font-size: 1.25rem;
      margin-bottom: 1.5rem;
    }
    .wizard-steps {
      display: flex;
      gap: 0.75rem;
      margin-bottom: 0.25rem;
      justify-content: center;
    }
    .wizard-step-dot {
      width: 2rem;
      height: 2rem;
      border-radius: 50%;
      background: var(--border);
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 0.6875rem;
      font-weight: 700;
      color: var(--text-muted);
    }
    .wizard-step-dot.active { background: var(--accent); color: white; }
    .wizard-step-dot.done { background: var(--green); color: white; }
    .wizard-step-labels {
      display: flex;
      gap: 0.75rem;
      justify-content: center;
      margin-bottom: 1.5rem;
    }
    .wizard-step-labels span {
      width: 2rem;
      text-align: center;
      font-size: 0.5625rem;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }
    .wizard-field { margin-bottom: 1rem; }
    .wizard-field label {
      display: block;
      font-size: 0.8125rem;
      color: var(--text-muted);
      margin-bottom: 0.25rem;
    }
    .wizard-field input,
    .wizard-field textarea,
    .wizard-field select {
      width: 100%;
      background: var(--bg);
      border: 1px solid var(--border);
      color: var(--text);
      padding: 0.5rem 0.75rem;
      border-radius: 0.375rem;
      font-size: 0.875rem;
      font-family: inherit;
    }
    .wizard-field textarea { resize: vertical; min-height: 3rem; }
    .wizard-field input:focus,
    .wizard-field textarea:focus,
    .wizard-field select:focus {
      outline: none;
      border-color: var(--accent);
    }
    .wizard-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }
    .wizard-btn-primary {
      background: var(--accent);
      border: none;
      color: #fff;
      padding: 0.5rem 1.25rem;
      border-radius: 0.375rem;
      font-size: 0.875rem;
      font-weight: 600;
      cursor: pointer;
    }
    .wizard-btn-primary:hover { background: var(--accent-light); }
    .wizard-btn-primary:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }
    .wizard-btn-secondary {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text);
      padding: 0.5rem 1.25rem;
      border-radius: 0.375rem;
      font-size: 0.875rem;
      cursor: pointer;
    }
    .wizard-btn-secondary:hover { border-color: var(--accent); }
    .wizard-token-box {
      background: var(--bg);
      border: 1px solid var(--amber);
      border-radius: 0.375rem;
      padding: 0.75rem;
      margin: 1rem 0;
      font-family: monospace;
      font-size: 0.75rem;
      word-break: break-all;
      color: var(--amber);
    }
    .wizard-success {
      text-align: center;
      padding: 1rem 0;
    }
    .wizard-success .check {
      font-size: 3rem;
      color: var(--green);
      margin-bottom: 0.75rem;
    }
    .wizard-spinner {
      display: inline-block;
      width: 1.25rem;
      height: 1.25rem;
      border: 2px solid var(--border);
      border-top-color: var(--accent);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
      vertical-align: middle;
      margin-right: 0.5rem;
    }
    @keyframes spin { to { transform: rotate(360deg); } }

    /* Share modal */
    .share-btn {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text-muted);
      padding: 0.375rem 0.75rem;
      border-radius: 0.375rem;
      cursor: pointer;
      font-size: 0.8125rem;
    }
    .share-btn:hover { border-color: var(--accent); color: var(--accent); }
    .share-tabs { display: flex; gap: 0; margin-bottom: 1rem; }
    .share-tab {
      background: var(--bg);
      border: 1px solid var(--border);
      color: var(--text-muted);
      padding: 0.375rem 0.75rem;
      cursor: pointer;
      font-size: 0.75rem;
      border-right: none;
    }
    .share-tab:last-child { border-right: 1px solid var(--border); }
    .share-tab:first-child { border-radius: 0.375rem 0 0 0.375rem; }
    .share-tab:last-child { border-radius: 0 0.375rem 0.375rem 0; }
    .share-tab.active {
      background: var(--accent);
      color: #fff;
      border-color: var(--accent);
      font-weight: 600;
    }
    .share-code-display {
      background: var(--bg);
      border: 2px solid var(--accent);
      border-radius: 0.5rem;
      padding: 1rem;
      text-align: center;
      font-family: monospace;
      font-size: 1.75rem;
      letter-spacing: 0.3em;
      color: var(--accent);
      margin: 1rem 0;
    }
    .share-field {
      background: var(--bg);
      border: 1px solid var(--border);
      border-radius: 0.375rem;
      padding: 0.5rem 0.75rem;
      font-family: monospace;
      font-size: 0.75rem;
      color: var(--text);
      word-break: break-all;
      margin: 0.5rem 0;
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
    .share-field span { flex: 1; }
    .copy-btn {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text-muted);
      padding: 0.25rem 0.5rem;
      border-radius: 0.25rem;
      cursor: pointer;
      font-size: 0.6875rem;
      white-space: nowrap;
    }
    .copy-btn:hover { color: var(--accent); border-color: var(--accent); }

    .patient-diagnosis {
      font-size: 0.6875rem;
      color: var(--text-muted);
      max-width: 12rem;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    /* Auth gate */
    .auth-gate {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 80vh;
      flex-direction: column;
      gap: 1rem;
      position: relative;
    }
    .auth-gate::before {
      content: '';
      position: absolute;
      top: 20%;
      left: 50%;
      transform: translateX(-50%);
      width: 400px;
      height: 400px;
      background: radial-gradient(circle, rgba(13, 148, 136, 0.06) 0%, transparent 70%);
      pointer-events: none;
    }
    .auth-gate input {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text);
      padding: 0.5rem 1rem;
      border-radius: 0.375rem;
      width: 300px;
      font-size: 0.875rem;
    }
    .auth-gate button {
      background: var(--accent);
      color: white;
      border: none;
      padding: 0.5rem 1.5rem;
      border-radius: 0.375rem;
      cursor: pointer;
      font-weight: 600;
    }

    /* Error banner */
    .error-banner {
      background: rgba(239, 68, 68, 0.15);
      border: 1px solid var(--red);
      border-radius: 0.5rem;
      padding: 0.75rem 1rem;
      margin: 1rem 0;
      display: none;
      font-size: 0.875rem;
    }
    .error-banner.visible { display: flex; align-items: center; justify-content: space-between; }

    /* MCP connection bar */
    .mcp-bar {
      display: flex;
      align-items: center;
      gap: 1.5rem;
      padding: 0.5rem 1rem;
      background: rgba(20, 184, 166, 0.05);
      border: 1px solid rgba(20, 184, 166, 0.15);
      border-radius: 8px;
      margin: 0.75rem 0;
      font-size: 0.75rem;
      flex-wrap: wrap;
    }
    .mcp-bar-item { display: flex; align-items: center; gap: 0.5rem; }
    .mcp-bar-label { color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 0.625rem; letter-spacing: 0.08em; }
    .mcp-bar code { background: var(--surface); padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.6875rem; color: var(--accent); }
    .copy-btn { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: 0.15rem 0.5rem; border-radius: 4px; cursor: pointer; font-size: 0.625rem; }
    .copy-btn:hover { border-color: var(--accent); color: var(--accent); }
    @media (max-width: 768px) { .mcp-bar { flex-direction: column; align-items: flex-start; gap: 0.5rem; } }

    /* Summary cards */
    .cards {
      display: grid;
      grid-template-columns: repeat(5, 1fr);
      gap: 0.75rem;
      margin: 1.25rem 0;
    }
    .card {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 0.75rem;
      padding: 1rem;
      text-align: center;
      transition: border-color 0.2s, box-shadow 0.2s;
      box-shadow: var(--card-shadow);
    }
    .card:hover { border-color: rgba(13, 148, 136, 0.3); box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
    .card .value {
      font-family: 'DM Serif Display', Georgia, serif;
      font-size: 1.75rem;
      font-weight: 400;
      color: var(--accent);
    }
    .card .label {
      font-size: 0.6875rem;
      color: var(--text-muted);
      text-transform: uppercase;
      letter-spacing: 0.04em;
      margin-top: 0.125rem;
    }
    .card.warning .value { color: var(--amber); }
    .card.danger .value { color: var(--red); }

    /* Pipeline funnel */
    .funnel {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 0.75rem;
      padding: 1.25rem;
      margin-bottom: 1.25rem;
      box-shadow: var(--card-shadow);
    }
    .funnel h2 { font-family: 'DM Serif Display', Georgia, serif; font-size: 1.0625rem; font-weight: 400; margin-bottom: 0.75rem; }
    .funnel-row {
      display: flex;
      align-items: center;
      margin-bottom: 0.5rem;
      font-size: 0.8125rem;
    }
    .funnel-label { width: 100px; color: var(--text-muted); flex-shrink: 0; }
    .funnel-bar-bg {
      flex: 1;
      height: 22px;
      background: rgba(0,0,0,0.04);
      border-radius: 4px;
      overflow: hidden;
      margin: 0 0.75rem;
    }
    .funnel-bar {
      height: 100%;
      border-radius: 4px;
      transition: width 0.4s ease;
      background: var(--accent);
    }
    .funnel-bar.complete { background: var(--green); }
    .funnel-count { width: 36px; text-align: right; font-weight: 600; font-size: 0.8125rem; }

    /* Filter pills */
    .filters {
      display: flex;
      gap: 0.5rem;
      flex-wrap: wrap;
      margin-bottom: 1rem;
    }
    .pill {
      background: var(--surface);
      border: 1px solid var(--border);
      color: var(--text-muted);
      padding: 0.3rem 0.75rem;
      border-radius: 9999px;
      font-size: 0.75rem;
      cursor: pointer;
      transition: all 0.15s;
    }
    .pill:hover { border-color: var(--accent); color: var(--text); }
    .pill.active { background: var(--accent); color: white; border-color: var(--accent); }
    .pill-count {
      display: inline-block;
      background: rgba(0,0,0,0.08);
      border-radius: 9999px;
      padding: 0 0.375rem;
      font-size: 0.625rem;
      margin-left: 0.25rem;
      min-width: 1rem;
      text-align: center;
    }
    .pill.active .pill-count { background: rgba(255,255,255,0.3); }

    /* Document table */
    .table-wrap {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 0.75rem;
      overflow-x: auto;
      margin-bottom: 1.25rem;
      box-shadow: var(--card-shadow);
    }
    table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
    th {
      text-align: left;
      padding: 0.625rem 0.75rem;
      border-bottom: 1px solid var(--border);
      color: var(--text-muted);
      font-weight: 600;
      font-size: 0.6875rem;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      cursor: pointer;
      user-select: none;
      white-space: nowrap;
    }
    th:hover { color: var(--accent); }
    th .sort-arrow { margin-left: 0.25rem; font-size: 0.625rem; }
    td {
      padding: 0.5rem 0.75rem;
      border-bottom: 1px solid var(--border);
      white-space: nowrap;
    }
    tr:last-child td { border-bottom: none; }
    tr:hover td { background: rgba(20,184,166,0.04); }
    .dot {
      display: inline-block;
      width: 8px;
      height: 8px;
      border-radius: 50%;
      vertical-align: middle;
    }
    .dot.green { background: var(--green); }
    .dot.red { background: var(--red); }
    .dot.amber { background: var(--amber); }
    .filename { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
    .filename a { color: var(--text); text-decoration: none; }
    .filename a:hover { color: var(--accent-light); text-decoration: underline; }
    .category-badge {
      display: inline-block;
      background: rgba(20,184,166,0.12);
      color: var(--accent-light);
      padding: 0.125rem 0.5rem;
      border-radius: 9999px;
      font-size: 0.6875rem;
    }
    .table-empty {
      text-align: center;
      padding: 2rem;
      color: var(--text-muted);
      font-size: 0.875rem;
    }
    .doc-detail-row td {
      border-bottom: 1px solid var(--border) !important;
    }
    /* Document detail split-pane */
    .doc-detail-panel {
      display: flex;
      gap: 1rem;
      padding: 1rem;
      background: var(--surface);
      border-radius: 0.5rem;
      position: relative;
    }
    .doc-detail-panel .detail-close {
      position: absolute;
      top: 0.5rem;
      right: 0.5rem;
      background: none;
      border: none;
      color: var(--text-muted);
      font-size: 1.25rem;
      cursor: pointer;
      line-height: 1;
      padding: 0.25rem 0.5rem;
      border-radius: 0.25rem;
    }
    .doc-detail-panel .detail-close:hover {
      color: var(--text);
      background: rgba(0,0,0,0.06);
    }
    /* Split ratio biased toward metadata side (#464). Left is the preview
       iframe — useful to have but not a full reading surface. Right carries
       structured data + OCR text that must stay discoverable without a
       horizontal scroll. flex 1 / 1.3 keeps both legible at typical widths. */
    .doc-detail-left {
      flex: 1 1 0;
      min-width: 0;
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
    }
    .doc-detail-left iframe {
      width: 100%;
      height: 420px;
      border: 1px solid var(--border);
      border-radius: 0.375rem;
      background: var(--bg-deep);
    }
    .doc-detail-right {
      flex: 1.3 1 0;
      min-width: 0;
      max-height: 480px;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 0.75rem;
    }
    .doc-detail-right::-webkit-scrollbar {
      width: 6px;
    }
    .doc-detail-right::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 3px;
    }
    .doc-ocr-page {
      background: var(--bg-deep);
      border: 1px solid var(--border);
      border-radius: 0.375rem;
      padding: 0.75rem;
    }
    .doc-ocr-page-header {
      font-size: 0.6875rem;
      font-weight: 600;
      color: var(--accent-light);
      margin-bottom: 0.5rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }
    .doc-ocr-text {
      font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', 'Menlo', monospace;
      font-size: 0.8125rem;
      line-height: 1.5;
      white-space: pre-wrap;
      word-break: break-word;
      user-select: text;
      color: var(--text);
      max-height: 200px;
      overflow-y: auto;
    }
    .doc-meta-section {
      display: flex;
      flex-direction: column;
      gap: 0.375rem;
      padding-top: 0.5rem;
      border-top: 1px solid var(--border);
    }
    .doc-meta-row {
      display: flex;
      gap: 0.5rem;
      font-size: 0.8125rem;
      line-height: 1.4;
    }
    .doc-meta-label {
      color: var(--text-muted);
      min-width: 7rem;
      flex-shrink: 0;
    }
    .doc-meta-value {
      color: var(--text);
      word-break: break-word;
    }
    .doc-meta-tags {
      display: flex;
      flex-wrap: wrap;
      gap: 0.25rem;
    }
    .doc-meta-tag {
      display: inline-block;
      background: rgba(20,184,166,0.12);
      color: var(--accent-light);
      padding: 0.0625rem 0.375rem;
      border-radius: 9999px;
      font-size: 0.6875rem;
    }
    .doc-detail-loading {
      text-align: center;
      padding: 2rem;
      color: var(--text-muted);
      font-size: 0.875rem;
    }
    .doc-detail-no-preview {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 300px;
      background: var(--bg-deep);
      border: 1px solid var(--border);
      border-radius: 0.375rem;
      color: var(--text-muted);
      font-size: 0.875rem;
    }
    .handwritten-badge {
      display: inline-block;
      background: rgba(245,158,11,0.15);
      color: var(--amber);
      padding: 0.0625rem 0.375rem;
      border-radius: 9999px;
      font-size: 0.6875rem;
      font-weight: 600;
    }
    @media (max-width: 768px) {
      .doc-detail-panel {
        flex-direction: column;
      }
      .doc-detail-left iframe {
        height: 280px;
      }
      .doc-detail-right {
        max-height: none;
      }
    }

    /* Remedies panel */
    .remedies {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 0.75rem;
      padding: 1.25rem;
      margin-bottom: 1.25rem;
      box-shadow: var(--card-shadow);
    }
    .remedies h2 { font-family: 'DM Serif Display', Georgia, serif; font-size: 1.0625rem; font-weight: 400; margin-bottom: 0.75rem; }
    .remedy-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0.5rem 0;
      border-bottom: 1px solid var(--border);
      font-size: 0.8125rem;
    }
    .remedy-row:last-child { border-bottom: none; }
    .remedy-label { color: var(--text-muted); }
    .remedy-count { font-weight: 600; color: var(--amber); margin: 0 0.5rem; }
    .remedy-action {
      font-family: 'SF Mono', 'Fira Code', monospace;
      font-size: 0.75rem;
      background: rgba(0,0,0,0.04);
      padding: 0.125rem 0.5rem;
      border-radius: 0.25rem;
      color: var(--text-muted);
    }

    /* Sync history */
    .sync-history {
      background: var(--surface);
      border: 1px solid var(--border);
      border-radius: 0.75rem;
      padding: 1.25rem;
      margin-bottom: 2rem;
      box-shadow: var(--card-shadow);
    }
    .sync-history h2 { font-family: 'DM Serif Display', Georgia, serif; font-size: 1.0625rem; font-weight: 400; margin-bottom: 0.75rem; }
    .sync-row {
      display: flex;
      align-items: center;
      gap: 1rem;
      padding: 0.375rem 0;
      font-size: 0.8125rem;
      border-bottom: 1px solid var(--border);
    }
    .sync-row:last-child { border-bottom: none; }
    .sync-time { color: var(--text-muted); width: 150px; flex-shrink: 0; font-size: 0.75rem; }
    .sync-status { width: 70px; flex-shrink: 0; font-weight: 600; }
    .sync-status.ok { color: var(--green); }
    .sync-status.fail { color: var(--red); }
    .sync-trigger { color: var(--text-muted); font-size: 0.75rem; }
    .sync-dur { color: var(--text-muted); font-size: 0.75rem; }

    /* Footer */
    footer {
      padding: 1rem 0;
      border-top: 1px solid var(--border);
      text-align: center;
      font-size: 0.75rem;
      color: var(--text-muted);
    }
    footer a { color: var(--text-muted); text-decoration: none; }
    footer a:hover { color: var(--accent-light); }

    /* Responsive */
    @media (max-width: 768px) {
      .cards { grid-template-columns: repeat(2, 1fr); }
      .funnel-label { width: 70px; font-size: 0.75rem; }
      .filename { max-width: 140px; }
      td { padding: 0.625rem 0.75rem; }
      .header-right { gap: 0.5rem; }
      .header-top { flex-wrap: wrap; }
      .header-account { flex-wrap: wrap; }
      .version { display: none; }
      .patient-controls { flex-wrap: wrap; gap: 0.375rem; }
      .mcp-bar { font-size: 0.6875rem; gap: 0.75rem; }
      .mcp-bar code { font-size: 0.5625rem; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
      /* Table: horizontal scroll for 11 columns */
      .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
      #doc-table { min-width: 900px; }
      /* Schedule rows: wrap on mobile */
      #sched-jobs > div { flex-wrap: wrap; gap: 0.375rem !important; }
    }
    @media (max-width: 480px) {
      .cards { grid-template-columns: repeat(2, 1fr); }
      .header-top { gap: 0.375rem; }
      .logo { font-size: 1rem; }
      .filters { gap: 0.375rem; flex-wrap: wrap; }
      .pill { font-size: 0.6875rem; padding: 0.25rem 0.5rem; }
      td { padding: 0.75rem 0.5rem; font-size: 0.75rem; }
      .funnel-label { width: 55px; font-size: 0.6875rem; }
      .share-btn, .add-patient-btn { font-size: 0.6875rem; padding: 0.25rem 0.5rem; }
      .doc-table { font-size: 0.6875rem; }
      .doc-table th, .doc-table td { padding: 0.375rem; }
      /* Hide less important table columns on small screens */
      #doc-table th:nth-child(3), #doc-table td:nth-child(3) { display: none; } /* Institution text */
      #doc-table th:nth-child(7), #doc-table td:nth-child(7) { display: none; } /* Meta dot */
      #doc-table th:nth-child(8), #doc-table td:nth-child(8) { display: none; } /* Date dot */
      #doc-table th:nth-child(9), #doc-table td:nth-child(9) { display: none; } /* Inst dot */
      #doc-table { min-width: 600px; }
    }

    .user-info {
      display: flex;
      align-items: center;
      gap: 0.5rem;
      font-size: 0.8125rem;
      color: var(--text-muted);
    }
    .user-info img {
      width: 24px;
      height: 24px;
      border-radius: 50%;
    }
    .logout-btn {
      background: none;
      border: 1px solid var(--border);
      color: var(--text-muted);
      padding: 0.25rem 0.5rem;
      border-radius: 0.375rem;
      cursor: pointer;
      font-size: 0.75rem;
    }
    .logout-btn:hover { border-color: var(--red); color: var(--red); }
    .connection-dot {
      display: inline-block;
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: var(--green);
      margin-right: 0.375rem;
      vertical-align: middle;
    }
    .connection-dot.offline { background: var(--red); }
    .connection-dot.loading { background: var(--amber); animation: pulse 1s infinite; }
    @keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
    /* Admin-only breaker widget (#469 Phase 7) — shows /readiness.circuit_breaker */
    .breaker-widget { display: none; align-items: center; gap: 0.25rem; font-size: 0.6875rem; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-right: 0.25rem; }
    .breaker-widget.admin-visible { display: inline-flex; }
    .breaker-widget .bw-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
    .breaker-widget.state-open .bw-dot { background: var(--red); animation: pulse 1s infinite; }
    .breaker-widget.state-half_open .bw-dot { background: var(--amber); animation: pulse 1s infinite; }
    .breaker-widget.has-trips { color: var(--amber); }
    .budget-pill { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.6875rem; color: var(--text-muted); font-variant-numeric: tabular-nums; margin-right: 0.25rem; padding: 0.15rem 0.4rem; border: 1px solid var(--border); border-radius: 999px; }
    .budget-pill .bp-icon { font-size: 0.8125rem; line-height: 1; }
    .budget-pill.state-warn { color: var(--amber); border-color: var(--amber); }
    .budget-pill.state-over { color: var(--red); border-color: var(--red); }
    .svc-badges { display: inline-flex; gap: 0.25rem; margin-right: 0.5rem; vertical-align: middle; }
    .svc-badge { font-size: 0.625rem; padding: 1px 5px; border-radius: 3px; font-weight: 600; letter-spacing: 0.02em; }
    .svc-badge.on { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.3); cursor: pointer; }
    .svc-badge.off { background: rgba(100,116,139,0.1); color: var(--text-dim); border: 1px solid var(--border); cursor: pointer; }
    .integration-popover { display:none; position:absolute; top:100%; right:0; z-index:100; background:var(--surface); border:1px solid var(--border); border-radius:0.5rem; padding:0.75rem 1rem; min-width:260px; box-shadow:0 4px 12px rgba(0,0,0,0.1); margin-top:0.25rem; }
    .integration-popover .ip-row { display:flex; justify-content:space-between; align-items:center; padding:0.25rem 0; font-size:0.8rem; }
    .integration-popover .ip-label { color:var(--text-dim); }
    .integration-popover .ip-value { color:var(--text); font-weight:500; }
    .integration-popover .ip-status { display:inline-block; width:6px; height:6px; border-radius:50%; margin-right:4px; }
    .integration-popover .ip-status.on { background:var(--green); }
    .integration-popover .ip-status.off { background:var(--text-dim); }
    .integration-popover .ip-actions { margin-top:0.5rem; padding-top:0.5rem; border-top:1px solid var(--border); }
    .integration-popover .ip-actions button { font-size:0.75rem; padding:3px 8px; border-radius:3px; border:1px solid var(--border); background:var(--bg); color:var(--text); cursor:pointer; }
    .integration-popover .ip-actions button:hover { background:var(--surface); }
    .integration-popover .ip-sync-time { font-size:0.65rem; color:var(--text-muted); margin-left:6px; }
    .skeleton {
      background: linear-gradient(90deg, var(--surface) 25%, var(--bg-deep) 50%, var(--surface) 75%);
      background-size: 200% 100%;
      animation: shimmer 1.5s infinite;
      border-radius: 0.375rem;
    }
    @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
    .card .value.skeleton { height: 2rem; width: 3rem; margin: 0 auto; }
    .funnel-row.skeleton .funnel-bar { background: var(--surface); }
    .auth-error {
      color: var(--red);
      font-size: 0.8125rem;
      margin-top: 0.75rem;
      display: none;
    }
    #g_id_signin { margin-top: 1rem; }
    .prompt-detail {
      font-family: 'DM Sans', monospace;
      color: var(--text-muted);
      line-height: 1.5;
    }
    .sync-row .sync-new {
      color: var(--green);
      font-size: 0.75rem;
      font-weight: 600;
    }
    #next-sync {
      font-style: italic;
    }

    /* #525: teal-hover replaces the inline onmouseover/onmouseout pair that
       previously toggled background:rgba(20,184,166,0.2) ↔ rgba(...,0.12). */
    .teal-hover {
      transition: background 0.18s ease;
    }
    .teal-hover:hover,
    .teal-hover:focus-visible {
      background: rgba(20, 184, 166, 0.2) !important;
    }
