/* ── Linear Design System — Therapy Flow Admin ──────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;510;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Background surfaces */
  --bg-canvas: #08090a;
  --bg-panel: #0f1011;
  --bg-surface: #191a1b;
  --bg-surface-hover: #28282c;
  --bg-elevated: #1e1f20;

  /* Text */
  --text-primary: #f7f8f8;
  --text-secondary: #d0d6e0;
  --text-tertiary: #8a8f98;
  --text-quaternary: #62666d;

  /* Brand accent */
  --accent-brand: #5e6ad2;
  --accent-violet: #7170ff;
  --accent-hover: #828fff;
  --accent-subtle: rgba(94, 106, 210, 0.15);

  /* Status */
  --status-green: #27a644;
  --status-emerald: #10b981;
  --status-orange: #f59e0b;
  --status-red: #ef4444;
  --status-blue: #3b82f6;
  --status-purple: #a855f7;

  /* Borders */
  --border-subtle: rgba(255,255,255,0.05);
  --border-standard: rgba(255,255,255,0.08);
  --border-strong: rgba(255,255,255,0.12);
  --border-solid: #23252a;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-pill: 9999px;

  /* Shadows */
  --shadow-focus: rgba(0,0,0,0.1) 0px 4px 12px;
  --shadow-elevated: rgba(0,0,0,0.4) 0px 2px 4px;
  --shadow-inset: rgba(0,0,0,0.2) 0px 0px 12px 0px inset;

  /* Layout */
  --sidebar-width: 240px;
  --sidebar-collapsed: 56px;
  --header-height: 44px;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-normal: 200ms ease;
}

/* ── Reset ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-feature-settings: "cv01", "ss03";
  font-weight: 400;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--bg-canvas);
  overflow-x: hidden;
}

a { color: var(--accent-violet); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Layout ────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition-normal);
}

.sidebar-brand {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
  height: 52px;
}

.sidebar-brand-icon {
  width: 24px; height: 24px;
  background: var(--accent-brand);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
}

.sidebar-brand-text {
  font-size: 14px;
  font-weight: 510;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 510;
  color: var(--text-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 16px 12px 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-md);
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 510;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  letter-spacing: -0.01em;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
}

.sidebar-item.active {
  background: var(--accent-subtle);
  color: var(--accent-violet);
  border-color: rgba(94, 106, 210, 0.2);
}

.sidebar-item-icon {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.sidebar-item-badge {
  margin-left: auto;
  background: var(--accent-subtle);
  color: var(--accent-violet);
  font-size: 11px;
  font-weight: 510;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
}

/* ── Main content ──────────────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-header {
  height: var(--header-height);
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
}

.main-header-title {
  font-size: 14px;
  font-weight: 510;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.main-header-breadcrumb {
  font-size: 13px;
  color: var(--text-quaternary);
}

.main-header-spacer { flex: 1; }

.main-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Login ─────────────────────────────────────────────────────────── */
#login-overlay {
  position: fixed; inset: 0;
  background: var(--bg-canvas);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}

.login-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-standard);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 380px;
  max-width: 90vw;
}

.login-card h2 {
  font-size: 20px;
  font-weight: 590;
  color: var(--text-primary);
  letter-spacing: -0.24px;
  margin-bottom: 4px;
}

.login-card p {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 24px;
}

/* ── Stat cards ────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-standard);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: all var(--transition-fast);
}

.stat-card:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--border-strong);
}

.stat-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.stat-card-icon {
  width: 32px; height: 32px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

.stat-card-label {
  font-size: 12px;
  font-weight: 510;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card-value {
  font-size: 32px;
  font-weight: 590;
  color: var(--text-primary);
  letter-spacing: -0.704px;
  line-height: 1.1;
}

.stat-card-change {
  font-size: 12px;
  font-weight: 510;
  margin-top: 6px;
}

/* ── Tables ────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead th {
  font-size: 12px;
  font-weight: 510;
  color: var(--text-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
  position: sticky;
  top: 0;
  background: var(--bg-panel);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: rgba(255,255,255,0.03);
}

.data-table tbody td {
  padding: 10px 12px;
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody td.primary-cell {
  color: var(--text-primary);
  font-weight: 510;
}

/* ── Panels / Cards ────────────────────────────────────────────────── */
.panel {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-standard);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 510;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.panel-header h3 {
  font-size: 13px;
  font-weight: 510;
  color: var(--text-secondary);
}

.panel-body {
  padding: 20px;
}

/* ── Badges / Pills ────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 510;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-pending   { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.badge-pending .badge-dot   { background: #f59e0b; }
.badge-sent      { background: rgba(59, 130, 246, 0.12); color: #3b82f6; }
.badge-sent .badge-dot      { background: #3b82f6; }
.badge-opened    { background: rgba(168, 85, 247, 0.12); color: #a855f7; }
.badge-opened .badge-dot    { background: #a855f7; }
.badge-completed { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.badge-completed .badge-dot { background: #10b981; }
.badge-reviewed  { background: rgba(138, 143, 152, 0.12); color: #8a8f98; }
.badge-reviewed .badge-dot  { background: #8a8f98; }

/* ── Buttons ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 510;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent-brand);
  color: #fff;
  border-color: transparent;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  border-color: var(--border-solid);
}
.btn-secondary:hover {
  background: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-tertiary);
  border-color: transparent;
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.2);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.2); }

.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn-lg { padding: 8px 20px; font-size: 14px; }

/* ── Forms ─────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 510;
  color: var(--text-tertiary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-standard);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent-brand);
  background: rgba(255,255,255,0.04);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-quaternary);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-select {
  appearance: none;
  background-color: rgba(255,255,255,0.04);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23d0d6e0'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 32px;
}

.form-select option,
.form-select optgroup {
  background: #ffffff;
  color: #111827;
}

.form-select option:checked {
  background: #5e6ad2;
  color: #ffffff;
}

.manual-keyboard-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 12px;
  align-items: start;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.manual-item-label {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.45;
  cursor: text;
}

.manual-response-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.manual-response-input {
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 15px;
  font-weight: 600;
  padding: 7px 8px;
}

.manual-response-input:focus {
  background: rgba(94, 106, 210, 0.16);
}

.manual-response-invalid {
  border-color: var(--status-red) !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.14) !important;
}

.manual-response-hint {
  font-size: 10px;
  color: var(--text-quaternary);
  line-height: 1.2;
  text-align: center;
}

.manual-submit-footer {
  position: sticky;
  bottom: 0;
  z-index: 5;
  margin: 18px -16px -16px;
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(17,24,39,0.72), var(--bg-secondary) 36%);
  border-top: 1px solid var(--border-subtle);
}

.manual-submit-footer .btn {
  width: 100%;
}

.assignment-list-item {
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast);
}

.assignment-list-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

.assignment-link-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(8px);
}

.assignment-link-dialog {
  width: min(760px, 100%);
  max-height: min(720px, 90vh);
  overflow: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 18px;
}

.assignment-link-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.assignment-link-head h3 {
  margin: 0 0 4px;
  color: var(--text-primary);
  font-size: 18px;
}

.assignment-link-head p {
  margin: 0;
  color: var(--text-quaternary);
  font-size: 13px;
}

.assignment-link-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.assignment-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.assignment-link-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.assignment-link-main strong {
  color: var(--text-primary);
}

.assignment-link-main span {
  color: var(--text-tertiary);
  font-size: 12px;
}

.assignment-link-main code {
  display: block;
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 11px;
}

@media (max-width: 640px) {
  .assignment-link-row {
    align-items: stretch;
    flex-direction: column;
  }
  .assignment-link-row .btn {
    width: 100%;
  }
}

.form-row {
  display: flex;
  gap: 12px;
}
.form-row > * { flex: 1; }

.form-hint {
  font-size: 12px;
  color: var(--text-quaternary);
  margin-top: 4px;
}

.variable-chip-wrap {
  margin-top: 8px;
  padding: 9px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.025);
}

.variable-chip-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-quaternary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 7px;
}

.variable-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.variable-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.variable-chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(94, 106, 210, 0.12);
}

.variable-chip code {
  color: var(--accent);
  font-size: 10px;
  background: transparent;
  padding: 0;
}

.variable-chip span {
  color: inherit;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
  accent-color: var(--accent-brand);
}

/* ── Tabs ──────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0;
}

.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 510;
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  letter-spacing: -0.01em;
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-brand);
}

.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

/* ── Questionnaire checkboxes ──────────────────────────────────────── */
.q-check-list {
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border-standard);
  border-radius: var(--radius-lg);
  padding: 4px;
}

.q-check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.q-check-item:hover {
  background: rgba(255,255,255,0.03);
}

.q-check-item input[type="checkbox"] {
  accent-color: var(--accent-brand);
  margin-top: 3px;
  flex-shrink: 0;
}

.q-check-item label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

.q-check-exp {
  margin: 6px 0 0 26px;
}

.q-check-exp textarea {
  width: 100%;
  font-size: 13px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  padding: 6px 10px;
  font-family: inherit;
  resize: vertical;
}

.q-check-exp textarea:focus {
  outline: none;
  border-color: var(--accent-brand);
}

/* ── List items ────────────────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  gap: 12px;
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: rgba(255,255,255,0.03); }

.list-item-main {
  flex: 1;
  min-width: 0;
}

.list-item-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ── Empty state ───────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-quaternary);
  font-size: 14px;
}

/* ── Filter bar ────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.filter-btn {
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 510;
  color: var(--text-tertiary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
}

.filter-btn.active {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border-color: var(--border-standard);
}

/* ── Toast / result ────────────────────────────────────────────────── */
.toast {
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 510;
  margin-top: 12px;
}

.toast-success { background: rgba(16, 185, 129, 0.12); color: #10b981; }
.toast-warning { background: rgba(245, 158, 11, 0.12); color: #f59e0b; }
.toast-error   { background: rgba(239, 68, 68, 0.12); color: #ef4444; }

/* ── Detail / Two column layout ─────────────────────────────────────── */
.split-layout {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 16px;
}

/* ── Scrollbar ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── Responsive ────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { width: var(--sidebar-collapsed); }
  .sidebar-brand-text,
  .sidebar-item span,
  .sidebar-section-label,
  .sidebar-item-badge { display: none; }
  .sidebar-item { justify-content: center; padding: 8px; }
  .split-layout { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .main-body { padding: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Mobile-first polish for admin screens ─────────────────────────── */
@media (max-width: 900px) {
  html { font-size: 15px; }
  body { overflow-x: hidden; }
  .app-layout {
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding-bottom: 64px;
  }
  .main-content { min-width: 0; overflow: visible; }
  .main-header {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 0 12px;
  }
  .main-header-breadcrumb,
  #header-date { display: none !important; }
  .main-body {
    overflow: visible;
    padding: 12px;
  }
  .panel { border-radius: 12px; min-width: 0; overflow: hidden; }
  .panel-header {
    padding: 12px;
    gap: 10px;
    align-items: flex-start;
  }
  .panel-header h2,
  .panel-header h3 { font-size: 15px; }
  .panel-body { padding: 12px; }
  .dashboard-two-col,
  .manual-entry-layout,
  .patients-layout,
  .split-layout {
    grid-template-columns: 1fr !important;
  }
  .form-row,
  .assignment-top-grid,
  .assignment-recipient-grid,
  .marker-row {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
  .form-input,
  .form-select,
  .form-textarea,
  select,
  textarea,
  input {
    max-width: 100%;
    font-size: 16px; /* avoid iOS zoom */
  }
  .btn { min-height: 40px; touch-action: manipulation; }
  .filter-bar,
  .compact-filter-bar,
  .assignment-email-tabs,
  .pd-tab-strip {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .filter-bar::-webkit-scrollbar,
  .compact-filter-bar::-webkit-scrollbar,
  .assignment-email-tabs::-webkit-scrollbar,
  .pd-tab-strip::-webkit-scrollbar { display: none; }
  .filter-btn,
  .email-tab,
  .pd-tab { flex: 0 0 auto; white-space: nowrap; }
  .q-card-grid,
  .pack-settings-grid { grid-template-columns: 1fr !important; }
  .q-card { min-height: auto; padding: 14px; }
  .assignment-actions,
  .report-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .assignment-actions .btn,
  .report-actions .btn { width: 100%; }
  .assignment-overview-panel { max-height: none; }
  .report-preview-wrap { padding: 10px; max-height: none; }
  .report-a4-page { padding: 12px !important; font-size: 10pt; overflow-x: auto; }
  table { max-width: 100%; }
}

@media (max-width: 640px) {
  .app-layout {
    display: block;
  }
  .sidebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 100;
    width: 100% !important;
    height: 58px;
    border-right: 0;
    border-top: 1px solid var(--border-subtle);
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-brand,
  .sidebar-section-label,
  .sidebar-footer { display: none !important; }
  .sidebar-nav {
    display: flex;
    gap: 6px;
    padding: 8px;
    overflow: visible;
    width: max-content;
    min-width: 100%;
  }
  .sidebar-item {
    min-width: 50px;
    min-height: 42px;
    justify-content: center;
    padding: 8px 10px !important;
  }
  .sidebar-item span:not(.sidebar-item-icon),
  .sidebar-item-badge { display: none !important; }
  .sidebar-item-icon { font-size: 18px; }
  .main-header-title { font-size: 15px; }
  .main-body { padding: 10px; }
  .login-card {
    width: calc(100vw - 24px);
    padding: 22px;
  }
  .stats-grid { grid-template-columns: 1fr !important; gap: 10px; }
  .stat-card { padding: 14px; }
  .assignment-section-head { align-items: stretch; flex-direction: column; }
  .marker-filter-wrap { min-width: 0; }
  .marker-filter-chips { justify-content: flex-start; max-width: none; }
  .pd-tab-strip { padding: 0 8px !important; }
  .pd-tab { padding: 10px 12px !important; }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Modern Assignment UI ─────────────────────────────────────────── */
.panel-subtitle { font-size: 12px; color: var(--text-quaternary); margin-top: 2px; }
.assignment-page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; max-width: 1180px; }
.assignment-create-panel { overflow: visible; }
.assignment-overview-panel { max-height: 360px; overflow: auto; }
.assignment-top-grid { display:grid; grid-template-columns: repeat(4, minmax(180px,1fr)); gap: 12px; align-items:end; }
.assignment-section-head { display:flex; justify-content:space-between; align-items:flex-end; gap:12px; margin: 10px 0 12px; }
.assignment-filter-wrap { min-width: 210px; }
.compact-select { height: 34px; font-size: 12px; }
.assignment-pack-bar { display:flex; flex-wrap:wrap; gap:8px; margin: 0 0 12px; }
.pack-pill { border:1px solid rgba(94,106,210,.35); background:rgba(94,106,210,.12); color:var(--accent-hover); border-radius:999px; padding:6px 10px; font-size:12px; font-weight:510; cursor:pointer; transition:all .15s ease; }
.pack-pill:hover { background:rgba(94,106,210,.22); transform:translateY(-1px); }
.q-card-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(240px,1fr)); gap: 10px; margin-bottom: 18px; }
.q-card { border:1px solid var(--border-standard); background:linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.015)); border-radius:12px; padding:12px; cursor:pointer; transition:all .15s ease; position:relative; min-height:106px; }
.q-card:hover { border-color:rgba(130,143,255,.35); background:rgba(255,255,255,.045); transform:translateY(-1px); }
.q-card.selected { border-color:rgba(113,112,255,.85); box-shadow:0 0 0 1px rgba(113,112,255,.35), 0 10px 30px rgba(0,0,0,.22); background:rgba(94,106,210,.14); }
.q-card-head { display:flex; align-items:flex-start; justify-content:space-between; gap:8px; }
.q-card-title { color:var(--text-primary); font-weight:600; font-size:13px; line-height:1.25; }
.q-card-code { color:var(--text-quaternary); font-size:11px; margin-top:4px; font-family:'JetBrains Mono', monospace; }
.q-card-check { width:20px; height:20px; border-radius:50%; border:1px solid var(--border-strong); display:flex; align-items:center; justify-content:center; color:white; font-size:11px; flex-shrink:0; }
.q-card.selected .q-card-check { background:var(--accent-brand); border-color:var(--accent-hover); }
.q-card-markers { display:flex; flex-wrap:wrap; gap:4px; margin-top:8px; }
.marker-chip { border:1px solid rgba(255,255,255,.08); background:rgba(255,255,255,.045); color:var(--text-tertiary); border-radius:999px; padding:2px 7px; font-size:10px; }
.q-card-config { display:none; margin-top:10px; padding-top:10px; border-top:1px solid var(--border-subtle); cursor:default; }
.q-card.selected .q-card-config { display:block; }
.q-card-config label { cursor:pointer; }
.lang-chip-row { display:flex; flex-wrap:wrap; gap:8px; margin:7px 0; }
.lang-chip { display:inline-flex; align-items:center; gap:5px; font-size:12px; color:var(--text-secondary); border:1px solid var(--border-subtle); border-radius:999px; padding:4px 8px; background:rgba(0,0,0,.12); }
.assignment-email-tabs { display:flex; gap:6px; border-bottom:1px solid var(--border-subtle); margin: 8px 0 14px; }
.email-tab { border:0; background:transparent; color:var(--text-tertiary); padding:8px 10px; cursor:pointer; font-size:13px; border-bottom:2px solid transparent; }
.email-tab.active { color:var(--accent-hover); border-bottom-color:var(--accent-brand); }
.generated-email-box { font-family:'JetBrains Mono', monospace; font-size:12px; line-height:1.45; }
.assignment-actions { display:flex; gap:10px; margin-top:12px; }
.assignment-actions .btn { flex:1; }
.compact-header { padding-top:10px; padding-bottom:10px; }
.compact-filter-bar { padding: 8px 12px !important; gap: 6px !important; }
.pack-settings-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap:10px; }
.pack-q-card { border:1px solid var(--border-subtle); border-radius:10px; padding:10px; background:rgba(255,255,255,.02); }
.pack-q-title { color:var(--text-primary); font-size:13px; font-weight:510; margin-bottom:8px; }
.marker-row { display:grid; grid-template-columns:minmax(220px,1fr) minmax(220px,1fr); gap:10px; align-items:center; padding:8px 0; border-bottom:1px solid var(--border-subtle); }
@media (max-width: 1100px) { .assignment-top-grid { grid-template-columns: repeat(2, minmax(180px,1fr)); } }
@media (max-width: 760px) { .assignment-top-grid, .marker-row { grid-template-columns:1fr; } .assignment-section-head { align-items:stretch; flex-direction:column; } }

/* Assignment layout adjustments: recipient fields after questionnaire grid + multi marker filter */
.assignment-patient-row { grid-template-columns: minmax(260px, 420px); margin-bottom: 14px; }
.assignment-recipient-grid { display:grid; grid-template-columns: repeat(3, minmax(180px,1fr)); gap:12px; margin: 6px 0 14px; padding: 12px; border:1px solid var(--border-subtle); border-radius:12px; background:rgba(255,255,255,.018); }
.marker-filter-title { font-size:11px; color:var(--text-quaternary); margin-bottom:6px; text-transform:uppercase; letter-spacing:.04em; }
.marker-filter-chips { display:flex; flex-wrap:wrap; gap:6px; justify-content:flex-end; max-width:520px; }
.marker-filter-chip { display:inline-flex; align-items:center; gap:5px; padding:5px 8px; border-radius:999px; border:1px solid var(--border-subtle); background:rgba(255,255,255,.035); color:var(--text-tertiary); font-size:12px; cursor:pointer; transition:all .15s ease; user-select:none; }
.marker-filter-chip:hover { color:var(--text-secondary); border-color:rgba(130,143,255,.35); }
.marker-filter-chip:has(input:checked) { background:rgba(94,106,210,.18); color:var(--accent-hover); border-color:rgba(113,112,255,.55); }
.marker-filter-chip input { accent-color: var(--accent-brand); }
.marker-filter-clear { border:1px solid var(--border-subtle); background:transparent; color:var(--text-quaternary); border-radius:999px; padding:5px 9px; font-size:12px; cursor:pointer; }
.marker-filter-clear:hover { color:var(--text-secondary); background:rgba(255,255,255,.045); }
.marker-filter-empty { color:var(--text-quaternary); font-size:12px; }
@media (max-width: 900px) { .assignment-recipient-grid { grid-template-columns:1fr; } .marker-filter-chips { justify-content:flex-start; max-width:none; } }

/* ── Result detail tabs / item answer archive ───────────────────────────── */
.result-detail-tabs { display:flex; gap:0; border-bottom:1px solid var(--border-subtle); margin:-16px -16px 16px; padding:0 16px; background:rgba(255,255,255,.015); }
.result-detail-tab { padding:12px 16px; border:0; border-bottom:2px solid transparent; background:transparent; color:var(--text-tertiary); font-size:13px; font-weight:510; cursor:pointer; }
.result-detail-tab:hover { color:var(--text-primary); }
.result-detail-tab.active { color:var(--accent); border-bottom-color:var(--accent); }
.result-detail-tab-panel { display:none; }
.result-detail-tab-panel.active { display:block; }
.result-detail-tab-panel .report-panel { margin-top:0; }
.result-answer-panel { margin-top:18px; border:1px solid var(--border-subtle); border-radius:14px; overflow:hidden; background:rgba(255,255,255,.02); }
.result-answer-head { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:12px 14px; border-bottom:1px solid var(--border-subtle); }
.result-answer-head h3 { margin:0; color:var(--text-primary); font-size:14px; font-weight:590; }
.result-answer-head span { color:var(--text-quaternary); font-size:11px; }
.result-meta-answer-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:8px; padding:12px 14px; border-bottom:1px solid var(--border-subtle); }
.result-meta-answer { display:flex; justify-content:space-between; gap:10px; padding:7px 9px; border:1px solid var(--border-subtle); border-radius:10px; font-size:12px; }
.result-meta-answer span { color:var(--text-quaternary); }
.result-meta-answer strong { color:var(--text-primary); font-weight:510; }
.result-answer-table-wrap { max-height:520px; overflow:auto; }
.result-answer-table { width:100%; border-collapse:collapse; }
.result-answer-table th { position:sticky; top:0; z-index:1; padding:8px; background:var(--bg-secondary); color:var(--text-tertiary); font-size:11px; text-align:left; border-bottom:1px solid var(--border-subtle); }

/* ── Result report preview / copy templates ─────────────────────────────── */
.report-panel { margin-top:18px; border:1px solid var(--border-subtle); border-radius:14px; background:rgba(255,255,255,.02); overflow:hidden; }
.report-panel-header { display:flex; justify-content:space-between; align-items:flex-start; gap:12px; padding:14px 16px; border-bottom:1px solid var(--border-subtle); }
.report-panel-header h3 { margin:0; color:var(--text-primary); font-size:15px; font-weight:590; }
.report-actions { display:flex; flex-wrap:wrap; gap:8px; justify-content:flex-end; }
.report-preview-wrap { background:#eef0f4; padding:18px; overflow:auto; max-height:720px; }
.report-a4-page { width:210mm; min-height:297mm; background:#fff; color:#111827; box-shadow:0 10px 25px rgba(0,0,0,.16); padding:20mm; box-sizing:border-box; font-family:'Segoe UI', Calibri, Arial, sans-serif; font-size:10pt; margin:0 auto; }
@media (max-width: 1100px) { .report-a4-page { width:100%; min-height:auto; padding:18px; } .report-panel-header { flex-direction:column; } .report-actions { justify-content:flex-start; } }


/* ── Dashboard / Results CRM polish ───────────────────────────────── */
.stat-card-click { cursor:pointer; position:relative; overflow:hidden; }
.stat-card-click:hover { border-color:rgba(130,143,255,.35); background:rgba(255,255,255,.045); transform:translateY(-1px); }
.stat-card-hint { margin-top:6px; color:var(--text-quaternary); font-size:11px; }
.dashboard-list-click:hover { background:rgba(255,255,255,.035); }
.mini-pill { display:inline-flex; align-items:center; justify-content:center; border:1px solid var(--border-subtle); background:rgba(255,255,255,.045); color:var(--text-tertiary); border-radius:999px; padding:3px 8px; font-size:11px; font-weight:510; white-space:nowrap; }
.results-dashboard-head { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; margin-bottom:14px; }
.results-dashboard-head h2 { color:var(--text-primary); font-size:22px; letter-spacing:-.03em; margin:0; }
.results-dashboard-head p { color:var(--text-tertiary); font-size:13px; margin-top:3px; }
.results-filter-panel { display:grid; grid-template-columns: minmax(240px,1.4fr) minmax(220px,1fr) minmax(140px,.65fr) minmax(140px,.65fr); gap:12px; padding:12px; border:1px solid var(--border-subtle); background:rgba(255,255,255,.02); border-radius:14px; margin-bottom:12px; align-items:end; }
.results-summary-strip { display:grid; grid-template-columns:repeat(4,minmax(120px,1fr)); gap:10px; margin-bottom:14px; }
.result-summary-card { border:1px solid var(--border-subtle); border-radius:12px; background:linear-gradient(180deg,rgba(255,255,255,.035),rgba(255,255,255,.015)); padding:12px; }
.result-summary-card span { display:block; color:var(--text-quaternary); font-size:11px; text-transform:uppercase; letter-spacing:.04em; }
.result-summary-card strong { display:block; color:var(--text-primary); font-size:20px; margin-top:2px; }
.results-layout { display:grid; grid-template-columns:minmax(260px,330px) minmax(0,1fr); gap:16px; align-items:start; }
.results-list-panel { position:sticky; top:58px; max-height:calc(100vh - 94px); overflow:hidden; }
.results-list-body { max-height:calc(100vh - 160px); overflow:auto; padding:8px !important; }
.result-card { border:1px solid var(--border-subtle); border-radius:12px; background:rgba(255,255,255,.018); padding:10px; margin-bottom:8px; transition:all .15s ease; }
.result-card:hover { background:rgba(255,255,255,.05); border-color:rgba(130,143,255,.35); transform:translateY(-1px); }
.result-card-top { display:flex; justify-content:space-between; align-items:flex-start; gap:8px; }
.result-card-patient { color:var(--text-primary); font-size:13px; font-weight:600; line-height:1.25; }
.result-card-test { color:var(--text-tertiary); font-size:12px; line-height:1.25; margin-top:4px; }
.result-card-meta { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; color:var(--text-quaternary); font-size:11px; }
.result-card-meta span { border:1px solid var(--border-subtle); border-radius:999px; padding:2px 7px; }
.results-detail-panel { min-width:0; }
.patient-crm-tools { padding:10px 12px; border-bottom:1px solid var(--border-subtle); }
.patient-filter-row { display:flex; flex-wrap:wrap; gap:6px; margin-top:8px; }
.crm-list-body { max-height:560px; overflow:auto; }
.patient-crm-card { display:flex; gap:10px; align-items:flex-start; padding:11px 12px; border-bottom:1px solid var(--border-subtle); transition:all .15s ease; }
.patient-crm-card:hover { background:rgba(255,255,255,.04); }
.patient-avatar { width:34px; height:34px; border-radius:50%; display:flex; align-items:center; justify-content:center; background:rgba(94,106,210,.18); color:var(--accent-hover); font-weight:700; flex-shrink:0; }
.patient-crm-main { min-width:0; flex:1; }
.patient-crm-title { color:var(--text-primary); font-weight:600; font-size:13px; line-height:1.2; }
.patient-crm-meta { color:var(--text-quaternary); font-size:11px; line-height:1.35; margin-top:2px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.patient-crm-side { margin-left:auto; }
.patients-crm-head { align-items:center; }
@media (max-width: 1050px) {
  .results-filter-panel { grid-template-columns:1fr 1fr; }
  .results-layout { grid-template-columns:1fr; }
  .results-list-panel { position:static; max-height:none; }
  .results-list-body { max-height:none; }
}
@media (max-width: 640px) {
  .results-dashboard-head { flex-direction:column; align-items:stretch; }
  .results-filter-panel, .results-summary-strip { grid-template-columns:1fr; }
  .patient-crm-side { display:none; }
}


/* ── Patient detail assignment composer ───────────────────────────────── */
.patient-assignment-panel { display:grid; gap:14px; }
.patient-assignment-hero { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; padding:14px; border:1px solid var(--border-subtle); border-radius:14px; background:linear-gradient(135deg, rgba(94,106,210,.12), rgba(255,255,255,.025)); }
.patient-assignment-kicker { color:var(--accent-hover); font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; margin-bottom:4px; }
.patient-assignment-hero h3 { color:var(--text-primary); font-size:18px; margin:0 0 4px; }
.patient-assignment-hero p { color:var(--text-tertiary); font-size:13px; line-height:1.4; margin:0; max-width:680px; }
.patient-assignment-head { margin-top:4px; }
.patient-q-card-grid { grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); }
.patient-recipient-grid { margin-top:2px; }
.patient-assignment-actions { justify-content:flex-start; }
@media (max-width: 720px) {
  .patient-assignment-hero { flex-direction:column; }
  .patient-q-card-grid { grid-template-columns:1fr; }
}


/* ── Therapy Flow pastel Zuweisungen redesign (from provided Vorlage) ───── */
#tab-assignments {
  --tf-cream-50:#FCFBF9;
  --tf-cream-100:#FAF8F5;
  --tf-cream-200:#F1ECE4;
  --tf-cream-300:#E4DBD0;
  --tf-lav-50:#F6F3FA;
  --tf-lav-100:#ECE6F4;
  --tf-lav-300:#BFABDA;
  --tf-lav-400:#9F8CBE;
  --tf-lav-500:#8E7AB5;
  --tf-lav-600:#755F9E;
  --tf-lav-700:#5C4A7E;
  --tf-mint-100:#DDEFEA;
  --tf-mint-500:#4D9684;
  --tf-charcoal:#2C2A29;
}
#tab-assignments.tf-tab-light,
#tab-assignments .tf-assignment-redesign { color:var(--tf-charcoal); }
#tab-assignments .tf-assignment-redesign { max-width:1220px; gap:18px; }
#tab-assignments .assignment-hero-card {
  position:relative; overflow:hidden; display:flex; align-items:center; justify-content:space-between; gap:24px;
  background:#fff; border:1px solid var(--tf-cream-300); border-radius:22px; padding:22px;
  box-shadow:0 1px 2px rgba(44,42,41,.05);
}
#tab-assignments .assignment-hero-art { position:absolute; inset:0 0 0 auto; width:38%; pointer-events:none; opacity:.75; background:radial-gradient(circle at 82% 42%, var(--tf-lav-100) 0 0, transparent 33%), radial-gradient(circle at 62% 74%, var(--tf-mint-100) 0 0, transparent 24%); }
#tab-assignments .assignment-hero-copy { position:relative; z-index:1; max-width:650px; }
#tab-assignments .assignment-kicker { color:var(--tf-mint-500); font-size:11px; font-weight:800; text-transform:uppercase; letter-spacing:.1em; margin-bottom:7px; }
#tab-assignments .assignment-hero-copy h2 { margin:0; color:var(--tf-charcoal); font-size:22px; letter-spacing:-.03em; }
#tab-assignments .assignment-hero-copy p { color:#746f68; font-size:13px; line-height:1.55; margin:7px 0 0; }
#tab-assignments .assignment-hero-patient { position:relative; z-index:1; width:min(360px,100%); flex-shrink:0; }
#tab-assignments .assignment-soft-panel,
#tab-assignments .assignment-overview-panel,
#tab-assignments .assignment-mail-panel { background:#fff; border:1px solid var(--tf-cream-300); border-radius:22px; box-shadow:0 1px 2px rgba(44,42,41,.05); }
#tab-assignments .assignment-soft-header { background:var(--tf-cream-50); border-bottom:1px solid var(--tf-cream-200); }
#tab-assignments .assignment-soft-header h3,
#tab-assignments .assignment-overview-panel h2 { color:var(--tf-charcoal); }
#tab-assignments .assignment-selected-count,
#tab-assignments .assignment-auto-pill { background:var(--tf-lav-100); color:var(--tf-lav-700); border:1px solid var(--tf-lav-100); border-radius:999px; padding:5px 10px; font-size:11px; font-weight:800; }
#tab-assignments .redesigned-section-head { align-items:center; margin-top:0; }
#tab-assignments .assignment-search-box { min-width:260px; flex:1; }
#tab-assignments .form-label { color:#8c877f; font-size:11px; font-weight:800; letter-spacing:.08em; }
#tab-assignments .form-input,
#tab-assignments .form-select,
#tab-assignments .form-textarea { background:var(--tf-cream-50); border-color:var(--tf-cream-300); color:var(--tf-charcoal); border-radius:13px; }
#tab-assignments .form-input:focus,
#tab-assignments .form-select:focus,
#tab-assignments .form-textarea:focus { border-color:var(--tf-lav-400); box-shadow:0 0 0 3px rgba(159,140,190,.22); }
#tab-assignments .btn-primary { background:var(--tf-lav-500); color:#fff; border-color:var(--tf-lav-500); box-shadow:0 6px 18px rgba(142,122,181,.20); }
#tab-assignments .btn-primary:hover { background:var(--tf-lav-600); border-color:var(--tf-lav-600); }
#tab-assignments .btn-secondary,
#tab-assignments .btn-ghost { background:#fff; color:#746f68; border-color:var(--tf-cream-300); }
#tab-assignments .btn-secondary:hover,
#tab-assignments .btn-ghost:hover { background:var(--tf-cream-100); color:var(--tf-charcoal); }
#tab-assignments .pack-pill { background:var(--tf-lav-50); color:var(--tf-lav-700); border-color:var(--tf-lav-100); }
#tab-assignments .pack-pill:hover { background:var(--tf-lav-100); }
#tab-assignments .q-card-grid { grid-template-columns:repeat(auto-fill,minmax(275px,1fr)); gap:16px; }
#tab-assignments .q-card { background:#fff; border:1px solid var(--tf-cream-300); border-radius:18px; padding:16px; min-height:124px; box-shadow:0 1px 2px rgba(44,42,41,.04); }
#tab-assignments .q-card:hover { border-color:var(--tf-lav-300); background:#fff; box-shadow:0 8px 24px rgba(44,42,41,.08); transform:translateY(-2px); }
#tab-assignments .q-card.selected { border:2px solid var(--tf-lav-400); background:#fff; box-shadow:0 10px 26px rgba(142,122,181,.16); }
#tab-assignments .q-card-title { color:var(--tf-charcoal); font-weight:800; font-size:13px; }
#tab-assignments .q-card-code { display:inline-block; margin-top:0; margin-bottom:7px; padding:2px 7px; border-radius:7px; background:var(--tf-cream-200); color:var(--tf-charcoal); font-size:10px; font-weight:800; text-transform:uppercase; }
#tab-assignments .q-card.selected .q-card-code { background:var(--tf-lav-100); color:var(--tf-lav-700); }
#tab-assignments .q-card-check { width:22px; height:22px; border-radius:7px; color:transparent; border-color:var(--tf-cream-300); }
#tab-assignments .q-card.selected .q-card-check { color:#fff; background:var(--tf-lav-500); border-color:var(--tf-lav-500); }
#tab-assignments .marker-chip { background:var(--tf-cream-50); border-color:var(--tf-cream-200); color:#9a948c; }
#tab-assignments .q-card.selected .marker-chip { background:var(--tf-lav-50); color:var(--tf-lav-600); border-color:var(--tf-lav-100); font-weight:700; }
#tab-assignments .q-card-config { border-top-color:var(--tf-cream-200); }
#tab-assignments .lang-chip { background:var(--tf-cream-50); border-color:var(--tf-cream-300); color:#625d57; }
#tab-assignments .assignment-mail-panel { overflow:hidden; margin-top:6px; }
#tab-assignments .assignment-mail-header { display:flex; align-items:center; justify-content:space-between; gap:12px; padding:14px 18px; background:var(--tf-cream-50); border-bottom:1px solid var(--tf-cream-200); color:var(--tf-charcoal); }
#tab-assignments .assignment-mail-header span:not(.assignment-auto-pill) { display:block; color:#8c877f; font-size:11px; margin-top:2px; }
#tab-assignments .assignment-recipient-grid { margin:0; border:0; border-radius:0; background:#fff; padding:18px; grid-template-columns:repeat(3,minmax(180px,1fr)); }
#tab-assignments .assignment-draft-preview { margin:0 18px 18px; padding:15px; background:var(--tf-cream-100); border:1px solid var(--tf-cream-300); border-radius:16px; }
#tab-assignments .assignment-draft-title { color:var(--tf-charcoal); font-size:11px; font-weight:900; letter-spacing:.06em; text-transform:uppercase; margin-bottom:10px; }
#tab-assignments .assignment-draft-subject { color:var(--tf-lav-600); font-size:13px; font-weight:800; margin-bottom:8px; }
#tab-assignments .assignment-draft-body { white-space:pre-wrap; max-height:180px; overflow:auto; color:#5f5a55; background:#fff; border:1px solid var(--tf-cream-200); border-radius:12px; padding:12px; font-size:12px; line-height:1.5; }
#tab-assignments .assignment-email-tabs { border-bottom-color:var(--tf-cream-200); }
#tab-assignments .email-tab { color:#8c877f; }
#tab-assignments .email-tab.active { color:var(--tf-lav-600); border-bottom-color:var(--tf-lav-500); }
#tab-assignments .variable-chip-wrap { background:var(--tf-cream-50); border-color:var(--tf-cream-200); }
#tab-assignments .assignment-actions { justify-content:flex-end; }
#tab-assignments .assignment-actions .btn { flex:0 1 auto; min-width:190px; }
#tab-assignments .marker-filter-chip { background:#fff; color:#827c75; border-color:var(--tf-cream-300); }
#tab-assignments .marker-filter-chip:has(input:checked) { background:var(--tf-lav-100); color:var(--tf-lav-700); border-color:var(--tf-lav-300); }
#tab-assignments .marker-filter-clear { background:#fff; color:#827c75; border-color:var(--tf-cream-300); }
@media (max-width:900px) {
  #tab-assignments .assignment-hero-card { flex-direction:column; align-items:stretch; }
  #tab-assignments .assignment-hero-art { width:100%; opacity:.35; }
  #tab-assignments .redesigned-section-head { align-items:stretch; flex-direction:column; }
  #tab-assignments .assignment-recipient-grid { grid-template-columns:1fr; }
  #tab-assignments .assignment-actions { flex-direction:column; }
  #tab-assignments .assignment-actions .btn { width:100%; }
}


/* ── Therapy Flow global pastel redesign + full-width tabs ─────────────── */
:root {
  --bg-canvas:#FAF8F5;
  --bg-panel:#FFFFFF;
  --bg-surface:#FFFFFF;
  --bg-surface-hover:#FCFBF9;
  --bg-elevated:#FFFFFF;
  --text-primary:#2C2A29;
  --text-secondary:#4F4A45;
  --text-tertiary:#7E776F;
  --text-quaternary:#A29A91;
  --accent-brand:#8E7AB5;
  --accent-violet:#755F9E;
  --accent-hover:#5C4A7E;
  --accent-subtle:rgba(142,122,181,.16);
  --border-subtle:#F1ECE4;
  --border-standard:#E4DBD0;
  --border-strong:#D9CCE9;
  --border-solid:#E4DBD0;
  --shadow-elevated:0 12px 30px rgba(44,42,41,.08);
}
html, body { background:#FAF8F5; color:#4F4A45; }
body { font-family:'Inter','Plus Jakarta Sans',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif; }
::-webkit-scrollbar { width:8px; height:8px; }
::-webkit-scrollbar-track { background:#FAF8F5; }
::-webkit-scrollbar-thumb { background:#E4DBD0; border-radius:999px; }
::-webkit-scrollbar-thumb:hover { background:#BFABDA; }
.app-layout { background:#FAF8F5; }
.sidebar { background:#fff; border-right:1px solid #E4DBD0; width:272px; }
.sidebar-brand { height:66px; padding:18px 22px; border-bottom:1px solid #F1ECE4; }
.sidebar-brand-icon { width:38px; height:38px; border-radius:14px; background:linear-gradient(135deg,#9F8CBE,#755F9E); box-shadow:0 8px 18px rgba(142,122,181,.22); font-size:0; position:relative; }
.sidebar-brand-icon::after { content:'TF'; font-size:12px; color:#fff; font-weight:900; letter-spacing:-.03em; }
.sidebar-brand-text { font-size:17px; font-weight:900; color:#2C2A29; letter-spacing:-.04em; }
.sidebar-brand-text::after { content:'Plattform'; display:block; color:#4D9684; font-size:9px; letter-spacing:.14em; text-transform:uppercase; margin-top:1px; }
.sidebar-nav { padding:14px 12px; }
.sidebar-section-label { color:#B1AAA2; font-size:10px; font-weight:900; letter-spacing:.12em; padding:18px 12px 7px; }
.sidebar-item { min-height:38px; padding:8px 12px; border-radius:14px; color:#7E776F; font-size:13px; font-weight:750; }
.sidebar-item:hover { background:#FAF8F5; color:#2C2A29; border-color:#F1ECE4; }
.sidebar-item.active { background:#F6F3FA; color:#5C4A7E; border-color:#ECE6F4; box-shadow:0 1px 2px rgba(44,42,41,.04); }
.sidebar-item-badge { background:#8E7AB5; color:#fff; font-weight:900; }
.sidebar-footer { border-top:1px solid #F1ECE4; }
.main-header { height:66px; background:#fff; border-bottom:1px solid #E4DBD0; padding:0 24px; }
.main-header-title { color:#2C2A29; font-size:18px; font-weight:900; letter-spacing:-.03em; }
.main-header-breadcrumb { background:#F1ECE4; color:#7E776F; border-radius:999px; padding:4px 10px; font-size:11px; font-weight:700; }
#header-date { background:#FCFBF9; border:1px solid #F1ECE4; border-radius:10px; padding:6px 10px; color:#9A928A !important; font-weight:650; }
.main-body { padding:24px; background:#FAF8F5; }
.tab-content { width:100%; max-width:none; }
.tab-content.active { display:block; }
.tab-content > * { max-width:none !important; width:100%; }
.assignment-page, .tf-assignment-redesign { max-width:none !important; width:100%; }
#tab-settings > .panel, #tab-settings .panel[style*="max-width"] { max-width:none !important; width:100%; }
.panel, .stat-card, .result-summary-card, .result-card, .patient-crm-card, .pack-q-card, .result-answer-panel, .report-panel { background:#fff; border:1px solid #E4DBD0; border-radius:18px; box-shadow:0 1px 2px rgba(44,42,41,.04); }
.panel { overflow:hidden; }
.panel-header { background:#FCFBF9; border-bottom:1px solid #F1ECE4; padding:16px 20px; }
.panel-header h2, .panel-header h3 { color:#2C2A29; font-weight:850; letter-spacing:-.02em; }
.panel-body { color:#4F4A45; }
.stats-grid { grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:18px; }
.stat-card { border-radius:20px; padding:22px; background:linear-gradient(180deg,#fff,#FCFBF9); }
.stat-card:hover, .stat-card-click:hover { border-color:#BFABDA; background:#fff; transform:translateY(-2px); box-shadow:0 10px 28px rgba(44,42,41,.08); }
.stat-card-label { color:#8E877F; font-weight:850; }
.stat-card-value { color:#2C2A29; font-weight:900; }
.stat-card-hint { color:#9A928A; }
.form-input, .form-select, .form-textarea { background:#FCFBF9; border:1px solid #E4DBD0; color:#2C2A29; border-radius:13px; }
.form-select { background-color:#FCFBF9; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23755F9E'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E"); }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color:#9F8CBE; background:#fff; box-shadow:0 0 0 3px rgba(159,140,190,.22); }
.form-label { color:#8C877F; font-weight:850; font-size:11px; letter-spacing:.08em; }
.form-hint, .empty-state { color:#8C877F; }
.btn { border-radius:12px; font-weight:800; }
.btn-primary { background:#8E7AB5; color:#fff; border-color:#8E7AB5; box-shadow:0 7px 18px rgba(142,122,181,.20); }
.btn-primary:hover { background:#755F9E; border-color:#755F9E; }
.btn-secondary, .btn-ghost { background:#fff; color:#746F68; border-color:#E4DBD0; }
.btn-secondary:hover, .btn-ghost:hover { background:#F6F3FA; color:#5C4A7E; border-color:#D9CCE9; }
.btn-danger { background:#fff1f2; color:#e11d48; border-color:#fecdd3; }
.filter-bar, .compact-filter-bar, .pd-tab-strip { background:#FCFBF9; border-color:#F1ECE4 !important; }
.filter-btn { background:#fff; border:1px solid #E4DBD0; color:#7E776F; border-radius:999px; font-weight:800; }
.filter-btn:hover, .filter-btn.active { background:#ECE6F4; color:#5C4A7E; border-color:#D9CCE9; }
.badge-pending { background:#fff7ed; color:#c2410c; }
.badge-sent { background:#eff6ff; color:#2563eb; }
.badge-opened { background:#F6F3FA; color:#755F9E; }
.badge-completed { background:#F0F9F7; color:#4D9684; }
.badge-reviewed { background:#F1ECE4; color:#746F68; }
.list-item, .assignment-list-item, .generated-link-row { border-color:#F1ECE4; background:#fff; color:#4F4A45; }
.list-item:hover, .assignment-list-item:hover, .dashboard-list-click:hover { background:#FCFBF9; border-color:#E4DBD0; }
.data-table thead th { background:#FCFBF9; color:#8C877F; border-bottom-color:#E4DBD0; }
.data-table tbody tr { border-bottom-color:#F1ECE4; }
.data-table tbody tr:hover { background:#FCFBF9; }
.data-table tbody td, .data-table tbody td.primary-cell { color:#2C2A29; }
.manual-keyboard-item { border-bottom-color:#F1ECE4; }
.manual-item-label { color:#2C2A29; }
.manual-response-input:focus { background:#F6F3FA; }
.manual-submit-footer { background:linear-gradient(180deg,rgba(250,248,245,0),#FAF8F5 24%); border-top-color:#F1ECE4; }
.variable-chip-wrap { background:#FCFBF9; border:1px solid #F1ECE4; border-radius:14px; }
.variable-chip { background:#fff; border-color:#E4DBD0; color:#7E776F; border-radius:999px; }
.variable-chip:hover { border-color:#BFABDA; color:#5C4A7E; background:#F6F3FA; }
.variable-chip code { color:#755F9E; }
.mini-pill { background:#F6F3FA; border-color:#ECE6F4; color:#755F9E; font-weight:850; }
.results-dashboard-head h2 { color:#2C2A29; }
.results-dashboard-head p { color:#7E776F; }
.results-filter-panel, .results-summary-strip .result-summary-card { background:#fff; border-color:#E4DBD0; }
.results-layout { grid-template-columns:minmax(320px,390px) minmax(0,1fr); width:100%; }
.results-list-panel { top:84px; }
.result-card-patient, .result-summary-card strong, .result-detail-tab-panel strong { color:#2C2A29; }
.result-card-test, .result-card-meta, .result-summary-card span { color:#7E776F; }
.patient-crm-card { border-left:0; border-right:0; border-top:0; border-radius:0; box-shadow:none; }
.patient-crm-card:hover { background:#FCFBF9; }
.patient-avatar { background:#ECE6F4; color:#755F9E; }
.patient-crm-title { color:#2C2A29; }
.patient-crm-meta { color:#8C877F; }
.pd-tab { color:#7E776F !important; }
.pd-tab-active { color:#755F9E !important; border-bottom-color:#8E7AB5 !important; }
.patient-assignment-hero { background:linear-gradient(135deg,#F6F3FA,#F0F9F7); border-color:#E4DBD0; border-radius:18px; }
.patient-assignment-kicker { color:#4D9684; }
.patient-assignment-hero h3 { color:#2C2A29; }
.patient-assignment-hero p { color:#746F68; max-width:none; }
.marker-chip, .marker-filter-chip, .marker-filter-clear, .pack-pill, .lang-chip { background:#fff; border-color:#E4DBD0; color:#7E776F; }
.marker-filter-chip:has(input:checked), .q-card.selected .marker-chip, .pack-pill:hover { background:#ECE6F4; color:#5C4A7E; border-color:#D9CCE9; }
.q-card { background:#fff; border-color:#E4DBD0; color:#4F4A45; border-radius:18px; box-shadow:0 1px 2px rgba(44,42,41,.04); }
.q-card:hover { background:#fff; border-color:#BFABDA; box-shadow:0 8px 24px rgba(44,42,41,.08); }
.q-card.selected { background:#fff; border-color:#9F8CBE; box-shadow:0 10px 26px rgba(142,122,181,.16); }
.q-card-title { color:#2C2A29; font-weight:850; }
.q-card-code { color:#746F68; background:#F1ECE4; border-radius:7px; padding:2px 7px; display:inline-block; }
.q-card-check { border-color:#E4DBD0; color:transparent; border-radius:7px; }
.q-card.selected .q-card-check { background:#8E7AB5; border-color:#8E7AB5; color:#fff; }
.q-card-config { border-top-color:#F1ECE4; }
.report-preview-wrap { background:#F1ECE4; }
.result-answer-table th { background:#FCFBF9; color:#8C877F; border-bottom-color:#E4DBD0; }
#login-overlay { background:radial-gradient(circle at 78% 22%,#ECE6F4 0 20%,transparent 42%),radial-gradient(circle at 18% 82%,#DDEFEA 0 18%,transparent 38%),#FAF8F5; }
.login-card { background:#fff; border:1px solid #E4DBD0; border-radius:24px; box-shadow:0 24px 60px rgba(44,42,41,.12); }
.login-card h2 { color:#2C2A29; font-weight:900; }
.login-card p { color:#7E776F; }
.toast-success, .toast.toast-success { background:#4D9684; color:#fff; border-color:#4D9684; }
.toast-error, .toast.toast-error { background:#fff1f2; color:#be123c; border-color:#fecdd3; }
#toast { background:#2C2A29; color:#fff; }
@media (max-width:1100px) {
  .manual-entry-layout, .patients-layout, .results-layout { grid-template-columns:1fr !important; }
  .results-list-panel { position:static; max-height:none; }
}
@media (max-width:768px) {
  .sidebar { width:64px; }
  .main-body { padding:16px; }
}


/* ── Select cleanup: remove custom purple dropdown triangles ───────────── */
.form-select,
select.form-select,
select {
  background-image:none !important;
  appearance:auto !important;
  -webkit-appearance:auto !important;
  -moz-appearance:auto !important;
  padding-right:12px !important;
}
.form-select::-ms-expand,
select::-ms-expand { display:block; }
.form-select:disabled,
.form-input[readonly] {
  background:#F1ECE4 !important;
  color:#746F68 !important;
  cursor:not-allowed;
}
