.tcv-shell {
    --tcv-ink: #18352f;
    --tcv-muted: #66736f;
    --tcv-paper: #fbfaf4;
    --tcv-line: #d9ded7;
    --tcv-accent: #1d6959;
    color: var(--tcv-ink);
    max-width: 1120px;
    margin: 0 auto;
}

.tcv-beta,
.tcv-security-note,
.tcv-notice {
    border-left: 5px solid #b7791f;
    background: #fff8df;
    padding: 14px 18px;
    margin: 0 0 22px;
}

.tcv-security-note {
    border-color: var(--tcv-accent);
    background: #edf7f3;
}

.tcv-notice-success { border-color: #2f855a; background: #f0fff4; }
.tcv-notice-error { border-color: #c53030; background: #fff5f5; }

.tcv-card,
.tcv-tree {
    background: var(--tcv-paper);
    border: 1px solid var(--tcv-line);
    border-radius: 12px;
    padding: 22px;
    margin: 0 0 20px;
    box-shadow: 0 8px 24px rgba(24, 53, 47, .05);
}

.tcv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 20px;
}

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

.tcv-button {
    display: inline-block;
    border: 0;
    border-radius: 999px;
    background: var(--tcv-accent);
    color: #fff !important;
    padding: 10px 20px;
    text-decoration: none !important;
    cursor: pointer;
}

.tcv-inline-form {
    display: inline;
    margin-left: 12px;
}

.tcv-link-button {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--tcv-accent);
    padding: 0;
    font: inherit;
    text-decoration: underline;
    cursor: pointer;
}

.tcv-danger-zone {
    border-color: #d7a5a5;
    background: #fffafa;
}

.tcv-danger-zone > summary {
    color: #8a2525;
    cursor: pointer;
    font-weight: 700;
}

.tcv-button-danger {
    background: #a62d2d;
}

.tcv-button-small {
    padding: 7px 14px;
    font-size: .88rem;
}

.tcv-button-secondary {
    background: #596864;
}

.tcv-checklist {
    display: grid;
    gap: 10px;
    margin: 20px 0;
}

.tcv-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0 0 12px;
    font-weight: 600;
}

.tcv-check input {
    flex: 0 0 auto;
    width: 1.15rem;
    height: 1.15rem;
    margin-top: .15rem;
}

.tcv-share-status {
    display: inline-block;
    border-radius: 999px;
    padding: 6px 12px;
    font-weight: 700;
}

.tcv-share-status.is-shared { background: #dff3e9; color: #185b4e; }
.tcv-share-status.is-private { background: #ecefed; color: #596864; }

.tcv-draft-restored,
.tcv-draft-status {
    color: var(--tcv-muted);
    font-size: .92rem;
}

.tcv-draft-restored {
    border-left: 4px solid var(--tcv-accent);
    background: #edf7f3;
    padding: 10px 14px;
}

.tcv-filter-bar {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(150px, .7fr) minmax(190px, .8fr) auto;
    gap: 12px;
    align-items: end;
    margin: 0 0 18px;
}

.tcv-filter-bar label {
    display: grid;
    gap: 6px;
    font-weight: 700;
}

.tcv-filter-bar input,
.tcv-filter-bar select {
    min-height: 42px;
    border: 1px solid #aebbb6;
    border-radius: 8px;
    background: #fff;
    padding: 8px 10px;
}

.tcv-revision-history {
    margin-top: 18px;
    border-top: 1px solid var(--tcv-line);
    padding-top: 12px;
}

.tcv-revision-history > summary,
.tcv-revision-history details > summary {
    cursor: pointer;
    font-weight: 700;
    padding: 7px 0;
}

.tcv-revision-history details {
    margin: 8px 0 0 16px;
}

.tcv-shared-practitioner > summary {
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 700;
}

.tcv-shared-practitioner ul {
    list-style: none;
    margin: 16px 0 0;
    padding: 0;
}

.tcv-shared-practitioner li {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 12px 4px;
    border-top: 1px solid var(--tcv-line);
}

.tcv-shared-practitioner li span {
    color: var(--tcv-muted);
}

.tcv-shared-search > summary {
    cursor: pointer;
    font-size: 1.08rem;
    font-weight: 700;
}

.tcv-shared-search form {
    margin-top: 18px;
}

.tcv-shared-search fieldset {
    margin: 0 0 22px;
    border: 1px solid var(--tcv-line);
    border-radius: 10px;
    padding: 16px;
}

.tcv-shared-search legend {
    padding: 0 7px;
    font-weight: 700;
}

.tcv-shared-search-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0 16px;
}

.tcv-search-results-heading {
    margin: 24px 0 10px;
}

.tcv-search-results-heading span {
    color: var(--tcv-muted);
}

.tcv-fields,
.tcv-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.tcv-field {
    display: grid;
    gap: 7px;
    margin: 0 0 16px;
    font-weight: 700;
}

.tcv-field textarea,
.tcv-field input,
.tcv-field select {
    width: 100%;
    border: 1px solid #aebbb6;
    border-radius: 8px;
    background: #fff;
    padding: 10px 12px;
    font: inherit;
}

.tcv-shell select {
    box-sizing: border-box;
    height: 46px;
    min-height: 46px;
    line-height: 1.5;
    padding-top: 8px;
    padding-bottom: 8px;
    vertical-align: middle;
}

.tcv-field .tcv-check input[type="checkbox"],
.tcv-field .tcv-check input[type="radio"] {
    flex: 0 0 1.15rem;
    width: 1.15rem;
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0;
}

.tcv-field textarea { min-height: 110px; }
.tcv-field small { color: var(--tcv-muted); font-weight: 400; }

.tcv-field-wide {
    grid-column: 1 / -1;
    border: 1px solid var(--tcv-line);
    border-radius: 10px;
    padding: 16px;
}

.tcv-field-wide legend {
    padding: 0 6px;
    font-weight: 700;
}

.tcv-field-help {
    margin: 0 0 12px;
    color: var(--tcv-muted);
    font-weight: 400;
}

.tcv-option-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px 14px;
}

.tcv-option-grid .tcv-check {
    margin: 0;
}

.tcv-proof-group > strong {
    display: block;
    margin-bottom: 10px;
}

.tcv-root-list,
.tcv-branch-list {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
}

.tcv-root-row {
    border: 1px solid var(--tcv-line);
    border-radius: 10px;
    padding: 14px;
}

.tcv-root-row-head {
    display: grid;
    grid-template-columns: minmax(170px, .7fr) minmax(210px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.tcv-root-row-head .tcv-field {
    margin: 0;
}

.tcv-root-point-groups {
    margin-top: 14px;
}

.tcv-branch-row {
    display: grid;
    grid-template-columns: minmax(190px, .75fr) minmax(260px, 1.25fr) auto;
    gap: 12px;
    align-items: end;
    border-bottom: 1px solid var(--tcv-line);
    padding: 0 0 12px;
}

.tcv-branch-row .tcv-field {
    margin: 0;
}

.tcv-remove-root,
.tcv-remove-branch {
    margin-bottom: 11px;
    white-space: nowrap;
}

.tcv-add-root,
.tcv-add-branch {
    padding: 8px 16px;
}

.tcv-tree ul,
.tcv-audit-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tcv-tree li,
.tcv-audit-list li {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--tcv-line);
}

.tcv-tree li:last-child,
.tcv-audit-list li:last-child { border-bottom: 0; }
.tcv-tree li span,
.tcv-audit-list small { color: var(--tcv-muted); }

.tcv-readonly {
    display: grid;
    grid-template-columns: minmax(150px, .35fr) 1fr;
    gap: 0;
}

.tcv-readonly dt,
.tcv-readonly dd {
    margin: 0;
    padding: 10px 4px;
    border-bottom: 1px solid var(--tcv-line);
}

.tcv-readonly dt { font-weight: 700; }
.tcv-visit h3 span { color: var(--tcv-muted); font-size: .75em; font-weight: 400; }

.tcv-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.tcv-images img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
}

.tcv-stats {
    display: flex;
    gap: 18px;
    margin: 0 0 20px;
}

.tcv-stats div {
    min-width: 160px;
    background: var(--tcv-ink);
    color: #fff;
    border-radius: 12px;
    padding: 18px;
}

.tcv-stats strong { display: block; font-size: 2rem; }
.tcv-stats span { opacity: .8; }

.tcv-members-entry {
    margin-top: 64px;
    padding-top: 18px;
    border-top: 1px solid #d8ddd8;
    color: #66736f;
    font-size: .9rem;
}

@media (max-width: 720px) {
    .tcv-fields,
    .tcv-grid { grid-template-columns: 1fr; }
    .tcv-toolbar { align-items: flex-start; flex-direction: column; }
    .tcv-shared-practitioner li { align-items: flex-start; flex-direction: column; }
    .tcv-tree li { align-items: flex-start; flex-direction: column; }
    .tcv-readonly { grid-template-columns: 1fr; }
    .tcv-readonly dt { border-bottom: 0; padding-bottom: 0; }
    .tcv-stats { flex-direction: column; }
    .tcv-filter-bar { grid-template-columns: 1fr; }
    .tcv-root-row-head,
    .tcv-branch-row { grid-template-columns: 1fr; }
    .tcv-remove-root,
    .tcv-remove-branch { justify-self: start; margin: 0; }
    .tcv-shared-search-grid { grid-template-columns: 1fr; }
}

@media (min-width: 721px) and (max-width: 980px) {
    .tcv-shared-search-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}


/* Compact grid for the new-patient basic-information screen. */
.tcv-workspace > .tcv-form > .tcv-card > .tcv-fields {
    gap: 10px 12px;
}

.tcv-workspace > .tcv-form > .tcv-card > .tcv-fields .tcv-field {
    gap: 4px;
    margin: 0 0 8px;
    font-size: .9rem;
}

.tcv-workspace > .tcv-form > .tcv-card > .tcv-fields .tcv-field input,
.tcv-workspace > .tcv-form > .tcv-card > .tcv-fields .tcv-field select {
    min-height: 40px;
    padding: 7px 9px;
}

@media (min-width: 1080px) {
    .tcv-workspace > .tcv-form > .tcv-card > .tcv-fields {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (min-width: 721px) and (max-width: 1079px) {
    .tcv-workspace > .tcv-form > .tcv-card > .tcv-fields {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
