:root {
    --ui-bg: #f4f7fb;
    --ui-surface: #ffffff;
    --ui-surface-muted: #f8fafc;
    --ui-border: #d8dee8;
    --ui-border-strong: #c4ccd8;
    --ui-text: #1f2937;
    --ui-text-muted: #546174;
    --ui-link: #2459a6;
    --ui-link-hover: #163f7d;
    --ui-primary: #1f6ed4;
    --ui-primary-hover: #1857a8;
    --ui-success: #1f8a4d;
    --ui-danger: #b02a2a;
    --ui-focus: rgba(31, 110, 212, 0.25);
    --ui-radius: 10px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
    color: var(--ui-text);
    background: linear-gradient(180deg, #f6f9fd 0%, #f2f5f9 100%);
    line-height: 1.45;
}

.page-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

h1,
h2,
h3 {
    color: #142033;
    margin-top: 0;
    letter-spacing: 0.01em;
}

h1 {
    font-size: 1.8rem;
    margin-bottom: 14px;
}

h2 {
    font-size: 1.25rem;
    margin-bottom: 10px;
}

h3 {
    font-size: 1.03rem;
    margin-bottom: 8px;
}

p,
li,
label,
input,
select,
textarea,
button,
a,
span,
div,
th,
td {
    font-size: 14px;
}

a {
    color: var(--ui-link);
    text-decoration: none;
}

a:hover {
    color: var(--ui-link-hover);
    text-decoration: underline;
}

.ui-link-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    border: 1px solid var(--ui-primary);
    background: var(--ui-primary);
    color: #fff;
    border-radius: 8px;
    padding: 9px 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.ui-link-button:hover {
    color: #fff;
    text-decoration: none;
    background: var(--ui-primary-hover);
    border-color: var(--ui-primary-hover);
    transform: translateY(-1px);
}

.ui-link-button.secondary {
    background: #fff;
    color: var(--ui-primary);
}

.ui-link-button.secondary:hover {
    background: #eef4ff;
    color: var(--ui-primary-hover);
}

.ui-link-button.danger {
    border-color: #c83f3f;
    background: #c83f3f;
    color: #fff;
}

.ui-link-button.danger:hover {
    border-color: #a93030;
    background: #a93030;
}

.clinician-home-actions {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 340px;
    margin: 0 auto;
    width: 100%;
}

.clinician-home-shell {
    min-height: 65vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.clinician-home-shell h1 {
    font-size: 3rem;
    margin-bottom: 22px;
}

.clinician-home-shell .ui-link-button {
    min-width: 280px;
    font-size: 1.1rem;
    padding: 12px 18px;
}

button,
input[type="submit"],
input[type="button"] {
    border: 1px solid var(--ui-primary);
    background: var(--ui-primary);
    color: #fff;
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

button:hover,
input[type="submit"]:hover,
input[type="button"]:hover {
    background: var(--ui-primary-hover);
    border-color: var(--ui-primary-hover);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    max-width: 100%;
    border: 1px solid var(--ui-border-strong);
    background: #fff;
    color: var(--ui-text);
    border-radius: 8px;
    padding: 9px 10px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    border-color: var(--ui-primary);
    box-shadow: 0 0 0 3px var(--ui-focus);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--ui-surface);
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    overflow: hidden;
}

thead th {
    background: #f2f6fb;
    color: #334155;
    font-weight: 700;
}

th,
td {
    border-bottom: 1px solid #e5e9f0;
    padding: 10px;
    vertical-align: top;
}

tr:last-child td {
    border-bottom: none;
}

ul {
    padding-left: 20px;
}

hr {
    border: 0;
    border-top: 1px solid var(--ui-border);
}

.page-card,
.form-card,
.panel,
div[style*="border: 1px solid #ccc"],
div[style*="border: 1px solid #ddd"] {
    background: var(--ui-surface);
    border-radius: var(--ui-radius);
    box-shadow: 0 4px 18px rgba(18, 31, 53, 0.05);
}

/* Base intake nav and progress */
.base-progress-track {
    width: 100%;
    background: #e8edf4;
    height: 18px;
    border-radius: 999px;
    overflow: hidden;
}

.base-progress-fill {
    background: linear-gradient(90deg, #2f9b58 0%, #1f8a4d 100%);
    height: 100%;
    border-radius: 999px;
    width: 0;
    transition: width 0.3s ease;
}

.base-section-nav {
    margin-bottom: 20px;
    padding: 12px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface-muted);
}

.base-section-nav ul {
    list-style: none;
    padding-left: 0;
    margin: 8px 0 0;
}

.base-section-nav li {
    padding: 5px 0;
}

.base-complete {
    color: var(--ui-success);
    font-weight: 600;
}

.intake-standard-form {
    margin-top: 8px;
}

.intake-standard-form fieldset {
    margin: 0 0 20px;
    padding: 14px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface-muted);
}

.intake-standard-form fieldset fieldset {
    background: #fff;
}

.intake-standard-form legend {
    color: #1b2b40;
    font-weight: 700;
    padding: 0 6px;
}

.intake-standard-form label {
    font-weight: 600;
}

.intake-standard-form input[type="text"],
.intake-standard-form input[type="email"],
.intake-standard-form input[type="password"],
.intake-standard-form input[type="date"],
.intake-standard-form input[type="number"],
.intake-standard-form select,
.intake-standard-form textarea {
    max-width: 640px;
}

.intake-standard-form textarea {
    min-height: 90px;
}

.intake-subcard {
    margin-bottom: 20px;
    padding: 12px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
}

.inline-error,
.error-text,
p[style*="color: red"],
div[style*="color: red"] {
    color: var(--ui-danger) !important;
}

/* Clinician cases UI controls */
.report-cell {
    min-width: 220px;
    max-width: 260px;
}

.status-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.status-queued,
.status-running {
    background: #e8f1ff;
    color: #1f4fa8;
}

.status-completed {
    background: #e8f8ee;
    color: #136f3b;
}

.status-failed {
    background: #fdecec;
    color: #9f2020;
}

.status-idle {
    background: #f1f3f5;
    color: #495057;
}

.progress-track {
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: #eef1f4;
    overflow: hidden;
    margin: 6px 0;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #2a7fff 0%, #1b5fcc 100%);
    transition: width 0.3s ease;
}

.template-panel {
    border: 1px solid #d8dde3;
    border-radius: 8px;
    padding: 10px;
    margin-top: 8px;
    background: #fafbfd;
}

.template-list {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid #e4e8ed;
    border-radius: 6px;
    padding: 8px;
    background: #fff;
}

.template-option {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 8px;
    font-size: 13px;
}

.template-option:last-child {
    margin-bottom: 0;
}

.report-actions-row {
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cases-filter-bar {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 10px 12px;
    align-items: end;
    margin: 14px 0 16px;
    padding: 10px;
    border: 1px solid #e1e5ea;
    border-radius: 8px;
    background: #fafbfd;
}

.clinician-cases-shell {
    max-width: 1240px !important;
    margin-left: auto;
    margin-right: auto;
}

.filter-search-wrap {
    grid-column: 1 / -1;
}

.filter-group {
    min-width: 0;
}

.cases-filter-bar input,
.cases-filter-bar select {
    height: 36px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    padding: 0 10px;
    font-size: 14px;
    background: #fff;
}

.cases-filter-bar input {
    min-width: 0;
    width: 100%;
}

.cases-filter-bar .filter-label {
    font-size: 12px;
    color: #5f6b76;
    margin-right: 4px;
    display: block;
    margin-bottom: 4px;
}

.cases-table-wrap {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--ui-radius);
}

.cases-table {
    min-width: 0;
    width: 100%;
}

.cases-table th,
.cases-table td {
    padding: 8px;
    font-size: 13px;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
}

.cases-table td:nth-child(5),
.cases-table td:nth-child(3),
.cases-table td:nth-child(2) {
    white-space: normal;
}

.case-code-cell {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    white-space: nowrap;
    min-width: 0;
}

.case-code-display {
    display: inline-block;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 12px;
    color: #2d3748;
    background: #eef2f8;
    border-radius: 6px;
    padding: 3px 6px;
}

.copy-code-btn {
    position: relative;
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    border: 0;
    background: transparent;
    color: #275a9f;
    border-radius: 0;
    padding: 0;
    font-size: 0;
    line-height: 0;
    box-shadow: none;
}

.copy-code-btn:hover {
    background: transparent;
    border: 0;
    box-shadow: none;
}

.copy-code-btn::before,
.copy-code-btn::after {
    content: "";
    position: absolute;
    width: 10px;
    height: 12px;
    border: 1.5px solid #275a9f;
    border-radius: 2px;
    background: #fff;
}

.copy-code-btn::before {
    top: 3px;
    left: 5px;
}

.copy-code-btn::after {
    top: 6px;
    left: 8px;
    background: #f8fbff;
}

.copy-code-btn.copied {
    background: transparent;
}

.copy-code-btn.copied::before,
.copy-code-btn.copied::after {
    border-color: #2e8b57;
}

.copy-code-btn.failed {
    background: transparent;
}

.copy-code-btn.failed::before,
.copy-code-btn.failed::after {
    border-color: #b02a2a;
}

.no-match-row {
    display: none;
}

.no-match-row td {
    padding: 14px 8px;
    color: #58606a;
    border-bottom: 1px solid #eee;
    font-style: italic;
}

@media (max-width: 860px) {
    .page-shell {
        padding: 16px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .report-cell {
        min-width: 180px;
        max-width: none;
    }

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        font-size: 13px;
    }

    .cases-filter-bar {
        grid-template-columns: 1fr;
    }

    .filter-search-wrap {
        grid-column: auto;
    }

    .cases-table {
        min-width: 0;
    }
}
