:root {
  /* Brand accent (logo option A: charcoal & gold). The --teal-* names are
     kept so every existing rule picks the gold up without renaming. */
  --teal-50: #fbf7ea;
  --teal-100: #f3e6c3;
  --teal-500: #c9a227;
  --teal-600: #8c6b14;
  --teal-700: #6e520c;
  --ink-900: #0f172a;
  --ink-700: #334155;
  --ink-500: #64748b;
  --ink-300: #cbd5e1;
  --ink-100: #f1f5f9;
  --ink-50: #f8fafc;
  --amber-500: #f59e0b;
  --amber-100: #fef3c7;
  --red-500: #ef4444;
  --red-100: #fee2e2;
  --green-600: #16a34a;
  --green-100: #dcfce7;
  --indigo-500: #6366f1;
  --violet-500: #a855f7;
  --sky-500: #0ea5e9;
  --sky-100: #e0f2fe;
  --rose-500: #f43f5e;
  --rose-100: #ffe4e6;
  --white: #ffffff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.10);
  /* Colorful gradient tiles used by the file viewer to tell photos, 3D
     scans and documents apart at a glance. */
  --grad-image: linear-gradient(135deg, #14b8a6 0%, #0ea5e9 100%);
  --grad-model: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --grad-doc: linear-gradient(135deg, #f59e0b 0%, #f97316 100%);
  --grad-other: linear-gradient(135deg, #64748b 0%, #475569 100%);
  /* Brand gradient — the topbar accent strip, primary buttons, gradient
     text, and the login/register backdrop all pull from this one so the
     "colorful" pass reads as one consistent identity rather than random
     accent colors scattered around. */
  --grad-brand: linear-gradient(90deg, #a8801a, #e2c25a 50%, #a8801a);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #f0fdfa 0%, #eff6ff 35%, #f5f3ff 70%, #fff1f2 100%);
  background-attachment: fixed;
  color: var(--ink-900);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.5;
}

a { color: var(--teal-700); }

.hidden { display: none !important; }

/* ---- Layout shells ---- */

.centered-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Soft blurred color blobs behind the login/register card — purely
   decorative, sits below the card (z-index) and never intercepts clicks. */
.centered-shell::before {
  content: '';
  position: absolute;
  inset: -20%;
  background:
    radial-gradient(circle at 15% 20%, rgba(20, 184, 166, 0.25), transparent 40%),
    radial-gradient(circle at 85% 15%, rgba(99, 102, 241, 0.22), transparent 40%),
    radial-gradient(circle at 50% 90%, rgba(244, 63, 94, 0.18), transparent 45%);
  filter: blur(40px);
  z-index: 0;
  pointer-events: none;
}
.centered-shell > * { position: relative; z-index: 1; }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--white);
  border-bottom: 3px solid transparent;
  border-image: var(--grad-brand) 1;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-weight: 700;
  font-size: 19.5px;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, var(--teal-700), var(--sky-500));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 12.5px;
  font-weight: 600;
  background: var(--teal-100);
  color: var(--teal-700);
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* Each portal gets its own accent color so the role is identifiable at a
   glance — set via a second class on the badge in each page's topbar. */
.brand-badge-technician { background: var(--sky-100); color: #0369a1; }
.brand-badge-qa { background: #eef2ff; color: #3730a3; }
.brand-badge-doctor { background: var(--rose-100); color: #be185d; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  color: var(--ink-500);
}

/* ---- Topbar identity (avatar + name + Account button) ---- */

.topbar-identity { display: flex; align-items: center; gap: 8px; }
.topbar-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--ink-100);
  box-shadow: 0 0 0 2px var(--teal-100);
}
.topbar-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grad-image);
  color: var(--white);
  font-weight: 700;
  font-size: 14px;
}
.topbar-identity-name { color: var(--ink-900); }
.topbar-identity-sub { color: var(--ink-500); font-weight: 400; }

/* ---- Account settings modal ---- */

.account-avatar-row { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.account-avatar-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--ink-100);
  box-shadow: 0 0 0 3px var(--teal-100);
}
.account-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grad-image);
  color: var(--white);
  font-weight: 700;
  font-size: 27.5px;
}

.main {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--ink-100);
  margin-bottom: 20px;
}

.tab-btn {
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-size: 16px;
  font-weight: 600;
  color: var(--ink-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.tab-btn.active {
  color: var(--teal-700);
  border-bottom: 2px solid;
  border-image: linear-gradient(90deg, var(--teal-500), var(--sky-500)) 1;
}

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

/* ---- Cards ---- */

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 18px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-header h2 {
  margin: 0;
  font-size: 18.5px;
}

.card-header p.subtitle {
  margin: 2px 0 0;
  font-size: 15px;
  color: var(--ink-500);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

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

/* ---- Auth ---- */

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  padding: 32px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 8px;
  font-size: 23px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--teal-600), var(--sky-500), var(--indigo-500));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.auth-sub {
  text-align: center;
  color: var(--ink-500);
  font-size: 15px;
  margin-bottom: 24px;
}

/* ---- Forms ---- */

label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-700);
  margin-bottom: 5px;
}

input[type="text"], input[type="password"], input[type="email"], input[type="number"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--ink-300);
  border-radius: 8px;
  font-size: 16px;
  background: var(--white);
  color: var(--ink-900);
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--teal-500);
  outline-offset: 0;
  border-color: var(--teal-500);
}

.field { margin-bottom: 16px; }

/* Password show/hide toggle — wraps any input[type=password] at runtime
   (see enablePasswordTogglesIn() in api.js). */
.password-field { position: relative; }
.password-field input { padding-right: 40px; }
.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--ink-500);
  cursor: pointer;
  padding: 0;
}
.password-toggle:hover { background: var(--ink-100); color: var(--ink-700); }
.password-toggle svg { width: 18px; height: 18px; }

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

.error-text {
  color: var(--red-500);
  font-size: 15px;
  margin-top: 10px;
  min-height: 0;
}

.help-text {
  color: var(--ink-500);
  font-size: 14.5px;
  margin-top: 4px;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.1s ease;
}
.btn:hover { filter: brightness(0.96); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--teal-600), var(--sky-500));
  color: var(--white);
  width: 100%;
  box-shadow: 0 2px 6px rgba(14, 165, 233, 0.25);
  transition: filter 0.1s ease, transform 0.1s ease, box-shadow 0.1s ease;
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: 0 4px 10px rgba(14, 165, 233, 0.32); }
.btn-secondary { background: var(--ink-100); color: var(--ink-700); }
.btn-outline { background: var(--white); color: var(--teal-700); border: 1px solid var(--teal-600); }
.btn-danger { background: var(--red-100); color: var(--red-500); }
.btn-sm { padding: 6px 12px; font-size: 15px; }
.btn-block { width: 100%; }

/* Shown in place of a Download control for patient photos a technician can
   view but not save — a quiet, clearly-inert badge rather than a button. */
.btn-disabled {
  background: var(--ink-100);
  color: var(--ink-500);
  border: 1px dashed var(--ink-300);
  cursor: not-allowed;
  user-select: none;
}
.btn-disabled:hover { filter: none; }

/* ---- Badges / status pills ---- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}
.pill-pending { background: var(--amber-100); color: #92400e; }
.pill-in_progress { background: #dbeafe; color: #1d4ed8; }
.pill-completed { background: var(--green-100); color: var(--green-600); }
.pill-role-management { background: var(--teal-100); color: var(--teal-700); }
.pill-role-technician { background: var(--ink-100); color: var(--ink-700); }
.pill-role-doctor { background: #ede9fe; color: #6d28d9; }
.pill-role-qa { background: #eef2ff; color: #3730a3; }
.pill-role-manager { background: var(--sky-100); color: #0369a1; }
.pill-pending-approval { background: var(--amber-100); color: #92400e; }
.pill-disapproved { background: var(--red-100); color: var(--red-500); }
.pill-neutral { background: var(--ink-100); color: var(--ink-700); }

/* ---- Production stage pipeline ---- */

.stage-pipeline { margin-bottom: 16px; }
.stage-list { display: flex; flex-direction: column; border: 1px solid var(--ink-100); border-radius: var(--radius); overflow: hidden; }
.stage-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ink-100);
  background: var(--white);
}
.stage-row:last-child { border-bottom: none; }
.stage-row.stage-completed { background: var(--teal-50); }
.stage-num {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--ink-100);
  color: var(--ink-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14.5px;
  font-weight: 700;
}
.stage-row.stage-in_progress .stage-num { background: #dbeafe; color: #1d4ed8; }
.stage-row.stage-completed .stage-num { background: var(--teal-600); color: var(--white); }
.stage-info { flex: 1; min-width: 0; }
.stage-label { font-weight: 600; font-size: 15.5px; }
.stage-meta { font-size: 14px; color: var(--ink-500); margin-top: 1px; }

/* ---- Revision banner: a doctor sent a version back for changes ---- */

.revision-banner {
  background: var(--amber-100);
  border: 1px solid #fbbf24;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 15.5px;
  color: #7c4a03;
}
.revision-banner strong { display: block; margin-bottom: 3px; }
/* Neutral variant for "submitted, waiting on someone else" states (e.g.
   awaiting QA) rather than an actual request for changes. */
.revision-banner-info {
  background: #eef2ff;
  border-color: var(--indigo-500);
  color: #3730a3;
}

/* ---- Deliverable versions / doctor review ---- */

.version-card {
  background: var(--white);
  border: 1px solid var(--ink-100);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.version-card-header { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.reject-note {
  margin-top: 12px;
  background: var(--red-100);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 15px;
  color: #7f1d1d;
}
.reject-note strong { display: block; margin-bottom: 2px; }
.version-review-actions { display: flex; gap: 10px; margin-top: 14px; }
.version-review-actions .btn { flex: 1; }

/* ---- Rejects list (management) ---- */

.reject-list { display: flex; flex-direction: column; gap: 8px; }
.reject-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--ink-100);
  border-radius: 8px;
  font-size: 15px;
}
.reject-row-main { flex: 1; }

/* ---- Raw change-history audit table (management) ---- */

.history-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.history-table th {
  text-align: left;
  color: var(--ink-500);
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  padding: 7px 8px;
  border-bottom: 1px solid var(--ink-100);
}
.history-table td { padding: 7px 8px; border-bottom: 1px solid var(--ink-100); vertical-align: top; }

/* ---- Case list ---- */

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

.case-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--ink-100);
  border-radius: 10px;
  background: var(--white);
}

.case-row-main { display: flex; flex-direction: column; gap: 4px; }
.case-row-title { font-weight: 600; font-size: 16.5px; }
.case-row-meta { font-size: 14.5px; color: var(--ink-500); display: flex; gap: 10px; flex-wrap: wrap; }
.case-row-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.empty-state {
  text-align: center;
  color: var(--ink-500);
  padding: 30px 10px;
  font-size: 16px;
}

/* ---- Activity feed ---- */

.feed { display: flex; flex-direction: column; gap: 10px; max-height: 420px; overflow-y: auto; }
.feed-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--ink-100); font-size: 15.5px; }
.feed-item:last-child { border-bottom: none; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--teal-500); }
.feed-dot.completed { background: var(--green-600); }
.feed-dot.accepted { background: #1d4ed8; }
.feed-dot.created { background: var(--amber-500); }
.feed-time { color: var(--ink-500); font-size: 14px; white-space: nowrap; }
.feed-text { color: var(--ink-900); }

/* ---- Stats ---- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
@media (max-width: 760px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  border-top: 3px solid var(--ink-100);
}
.stat-value { font-size: 27.5px; font-weight: 700; color: var(--ink-900); }
.stat-label { font-size: 14.5px; color: var(--ink-500); margin-top: 2px; }

/* Each card in the overview strip means something different (pending /
   in progress / awaiting QC / completed / turnaround), so the accent color
   carries that meaning instead of being decoration — same palette as the
   status pills elsewhere, so "amber" always means "pending" across the app. */
.stat-card:nth-child(1) { border-top-color: var(--amber-500); }
.stat-card:nth-child(1) .stat-value { color: #b45309; }
.stat-card:nth-child(2) { border-top-color: var(--sky-500); }
.stat-card:nth-child(2) .stat-value { color: #0369a1; }
.stat-card:nth-child(3) { border-top-color: var(--violet-500); }
.stat-card:nth-child(3) .stat-value { color: #7e22ce; }
.stat-card:nth-child(4) { border-top-color: var(--green-600); }
.stat-card:nth-child(4) .stat-value { color: var(--green-600); }
.stat-card:nth-child(5) { border-top-color: var(--teal-500); }
.stat-card:nth-child(5) .stat-value { color: var(--teal-700); }

/* ---- Drive browser ---- */

.drive-breadcrumbs { display: flex; flex-wrap: wrap; gap: 4px; font-size: 15px; margin-bottom: 10px; color: var(--ink-500); }
.drive-breadcrumbs button { background: none; border: none; color: var(--teal-700); cursor: pointer; font-size: 15px; padding: 0; }
.drive-list { display: flex; flex-direction: column; border: 1px solid var(--ink-100); border-radius: 8px; max-height: 320px; overflow-y: auto; }
.drive-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-bottom: 1px solid var(--ink-100); font-size: 15.5px;
}
.drive-item:last-child { border-bottom: none; }
.drive-item-name { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.drive-item-name.folder { font-weight: 600; }

/* ---- Team table ---- */

table.team-table { width: 100%; border-collapse: collapse; font-size: 15.5px; }
table.team-table th { text-align: left; color: var(--ink-500); font-weight: 600; font-size: 14px; text-transform: uppercase; letter-spacing: 0.02em; padding: 8px 10px; border-bottom: 1px solid var(--ink-100); }
table.team-table td { padding: 10px; border-bottom: 1px solid var(--ink-100); vertical-align: middle; }

/* Scrollable wrapper for long account lists (e.g. the Doctors tab) — keeps
   the header row and page layout stable while the rows scroll internally. */
.scroll-table-wrap { max-height: 460px; overflow-y: auto; }
.scroll-table-wrap table.team-table thead th { position: sticky; top: 0; background: var(--white); z-index: 1; }

/* ---- Timer ---- */

.timer-box {
  display: flex; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums;
  font-weight: 700; color: var(--teal-700);
}

/* ---- Toast ---- */

#toast-stack {
  position: fixed; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100;
}
.toast {
  background: var(--ink-900); color: white; padding: 10px 16px; border-radius: 8px; font-size: 15.5px;
  box-shadow: var(--shadow-md); max-width: 320px;
  animation: toast-in 0.15s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Modal ---- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45); display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal {
  background: var(--white); border-radius: 12px; box-shadow: var(--shadow-md); padding: 22px; width: 100%; max-width: 480px; max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal-close-btn {
  position: sticky; top: 0; float: right; margin: -4px -4px 0 12px;
  width: 30px; height: 30px; border-radius: 50%; border: none; background: var(--ink-100);
  color: var(--ink-600); font-size: 19.5px; line-height: 1; cursor: pointer; z-index: 5;
  display: flex; align-items: center; justify-content: center;
}
.modal-close-btn:hover { background: var(--ink-200); color: var(--ink-800); }

.file-drop {
  border: 1.5px dashed var(--ink-300); border-radius: 8px; padding: 18px; text-align: center; font-size: 15.5px; color: var(--ink-500); cursor: pointer;
}
.file-drop.dragover { border-color: var(--teal-500); background: var(--teal-50); }
.file-chip-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.file-chip { display: flex; align-items: center; justify-content: space-between; background: var(--ink-100); padding: 6px 10px; border-radius: 6px; font-size: 14.5px; }
.file-chip button { border: none; background: none; color: var(--red-500); cursor: pointer; font-size: 14px; }

.progress-bar { height: 6px; background: var(--ink-100); border-radius: 4px; overflow: hidden; margin-top: 8px; }

/* ---- File grid (thumbnails for case intake/deliverable files) ---- */

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.file-card {
  border: 1px solid var(--ink-100);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--white);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.file-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--teal-100);
}
.file-thumb {
  width: 100%;
  height: 96px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--ink-100);
  cursor: zoom-in;
  display: block;
  transition: transform 0.2s ease;
}
.file-card:hover .file-thumb { transform: scale(1.03); }

.file-thumb-icon {
  position: relative;
  width: 100%;
  height: 96px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  overflow: hidden;
  color: var(--white);
}
.file-thumb-icon svg { width: 28px; height: 28px; position: relative; z-index: 1; flex-shrink: 0; }
.file-thumb-icon.kind-image { background: var(--grad-image); }
.file-thumb-icon.kind-model { background: var(--grad-model); }
.file-thumb-icon.kind-pdf { background: var(--grad-doc); }
.file-thumb-icon.kind-other { background: var(--grad-other); }

/* A faint isometric grid behind 3D-scan tiles hints at a scan viewport
   instead of a flat generic icon. */
.file-thumb-icon.kind-model::before,
.file-viewer-placeholder-icon.kind-model::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 13px 13px;
  transform: perspective(110px) rotateX(50deg) scale(1.7);
  transform-origin: bottom;
}

.file-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-700);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-card-meta {
  font-size: 12px;
  color: var(--ink-500);
  display: flex;
  align-items: center;
  gap: 5px;
}
.file-card-meta-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.file-card-meta-dot.kind-image { background: var(--teal-500); }
.file-card-meta-dot.kind-model { background: var(--indigo-500); }
.file-card-meta-dot.kind-pdf,
.file-card-meta-dot.kind-other { background: var(--amber-500); }

.file-card .btn { text-align: center; }
.file-card.active {
  border-color: var(--teal-500);
  box-shadow: 0 0 0 2px var(--teal-100), var(--shadow-md);
}

#case-detail-modal { max-width: 800px; }

/* ---- File viewer (dropdown + large central preview, above the grid) ---- */

.file-viewer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  background: var(--ink-50);
  border: 1px solid var(--ink-100);
  border-radius: 999px;
  padding: 5px 5px 5px 14px;
}
.file-viewer-select {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  font-weight: 600;
  color: var(--ink-900);
  padding-left: 0;
}
.file-viewer-select:focus { outline: none; }
.file-viewer-nav-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--white);
  color: var(--teal-700);
  font-size: 20.5px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.file-viewer-nav-btn:hover { background: var(--teal-500); color: var(--white); transform: scale(1.06); }

.file-viewer-stage {
  position: relative;
  background: linear-gradient(180deg, var(--ink-50) 0%, var(--white) 100%);
  border: 1px solid var(--ink-100);
  border-radius: 14px;
  min-height: 260px;
  max-height: 420px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 14px;
  margin-bottom: 14px;
}
.file-viewer-stage::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--grad-image);
}
.file-viewer-image-wrap {
  position: relative;
  display: inline-flex;
  cursor: zoom-in;
  animation: viewer-fade-in 0.18s ease;
}
.file-viewer-image {
  max-width: 100%;
  max-height: 380px;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  display: block;
}
.file-viewer-maximize-hint {
  position: absolute;
  right: 10px;
  bottom: 10px;
  background: rgba(15, 23, 42, 0.68);
  color: var(--white);
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 5px;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.file-viewer-image-wrap:hover .file-viewer-maximize-hint { opacity: 1; }
.file-viewer-maximize-hint svg { width: 12px; height: 12px; }

.file-viewer-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 20px;
  color: var(--ink-500);
  animation: viewer-fade-in 0.18s ease;
}
.file-viewer-placeholder-icon {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  color: var(--white);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.file-viewer-placeholder-icon svg { width: 36px; height: 36px; position: relative; z-index: 1; }
.file-viewer-placeholder-icon.kind-image { background: var(--grad-image); }
.file-viewer-placeholder-icon.kind-model { background: var(--grad-model); }
.file-viewer-placeholder-icon.kind-pdf { background: var(--grad-doc); }
.file-viewer-placeholder-icon.kind-other { background: var(--grad-other); }
.file-viewer-placeholder-text { font-weight: 700; color: var(--ink-900); font-size: 16.5px; }
.file-viewer-placeholder-sub { font-size: 14.5px; margin-top: 4px; max-width: 320px; }
.file-viewer-placeholder .btn-primary { width: auto; margin-top: 14px; }

.file-grid-compact { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.file-grid-compact .file-thumb,
.file-grid-compact .file-thumb-icon { height: 68px; }
.file-grid-compact .file-thumb-icon svg { width: 24px; height: 24px; }

@keyframes viewer-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Image preview lightbox (maximize a photo full-screen) ---- */

.image-preview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 15, 30, 0.92);
  backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}
.image-preview-overlay.open { display: flex; animation: lightbox-fade-in 0.15s ease; }
.image-preview-box {
  background: transparent;
  border-radius: 14px;
  overflow: visible;
  max-width: 94vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.image-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 4px 14px;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--white);
}
.image-preview-count {
  font-weight: 600;
  color: var(--white);
  background: rgba(255, 255, 255, 0.16);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 13px;
  margin-left: 6px;
}
.image-preview-header button {
  border: none;
  background: rgba(255, 255, 255, 0.12);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.image-preview-header button:hover { background: rgba(255, 255, 255, 0.26); }
.image-preview-header .btn-outline {
  width: auto;
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--white);
  background: rgba(255, 255, 255, 0.1);
}
.image-preview-header .btn-outline:hover { background: rgba(255, 255, 255, 0.2); }
.image-preview-box img {
  max-width: 90vw;
  max-height: 76vh;
  object-fit: contain;
  display: block;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: lightbox-image-in 0.18s ease;
}
.image-preview-body { position: relative; display: flex; align-items: center; justify-content: center; }
.image-preview-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.12);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.2);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 25.5px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.15s ease;
}
.image-preview-nav:hover { background: var(--teal-500); transform: translateY(-50%) scale(1.06); border-color: transparent; }
.image-preview-prev { left: 4px; }
.image-preview-next { right: 4px; }

@keyframes lightbox-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes lightbox-image-in { from { opacity: 0; transform: scale(0.98); } to { opacity: 1; transform: scale(1); } }

.progress-bar-fill { height: 100%; background: var(--teal-500); transition: width 0.2s ease; }

/* ---- File card: uniform tiles, single-line action pinned to the bottom ---- */
.file-card { min-width: 0; }
.file-card .file-card-action {
  margin-top: auto;
  width: 100%;
  padding: 5px 6px;
  font-size: 13px;
  white-space: nowrap;
}
.file-card-tag {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 999px;
  background: var(--ink-50);
  color: var(--ink-500);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.file-card-tag svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ---- Technician: overview list + three-page case workspace ---- */
.active-case-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.active-case-title-row h2 { margin: 0; }
.pill-sent-back { background: var(--rose-100); color: var(--rose-500); }

.case-row-clickable { cursor: pointer; transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease; }
.case-row-clickable:hover { border-color: var(--teal-100); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.active-row { border-left: 4px solid var(--sky-500); }
.active-row-qa { border-left-color: var(--ink-300, #cbd5e1); }
.active-row-changes { border-left-color: var(--rose-500); }
.active-row .case-row-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-timer {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 15px;
  color: var(--teal-700);
  background: var(--teal-100);
  padding: 4px 10px;
  border-radius: 999px;
}
.case-row-actions { display: flex; align-items: center; gap: 10px; }

.ws-back {
  background: none;
  border: none;
  color: var(--teal-700);
  font-weight: 600;
  font-size: 15.5px;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 10px;
}
.ws-back:hover { text-decoration: underline; }
.ws-header { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.ws-header .subtitle { margin: 4px 0 0; }

.ws-subtabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 0 14px;
}
.ws-subtab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 10px;
  border-radius: 12px;
  border: 1px solid var(--ink-100);
  background: var(--white);
  font-weight: 600;
  font-size: 16px;
  color: var(--ink-700);
  cursor: pointer;
  transition: all 0.15s ease;
}
.ws-subtab:hover { border-color: var(--teal-100); color: var(--teal-700); }
.ws-subtab.active {
  background: var(--grad-brand);
  color: var(--white);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.25);
}
.ws-subtab-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  background: var(--ink-100);
  color: var(--ink-700);
}
.ws-subtab.active .ws-subtab-num { background: rgba(255, 255, 255, 0.25); color: var(--white); }
.ws-subtab-badge { font-size: 13px; opacity: 0.85; font-weight: 700; }
.ws-subtab-badge:empty { display: none; }

.ws-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.ws-info-item {
  background: var(--ink-50);
  border: 1px solid var(--ink-100);
  border-radius: 10px;
  padding: 10px 12px;
  min-width: 0;
}
.ws-info-label { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-500); font-weight: 700; }
.ws-info-value { font-size: 16px; font-weight: 600; color: var(--ink-900); margin-top: 3px; overflow-wrap: anywhere; }
.ws-files-block + .ws-files-block { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--ink-100); }
.ws-panel .file-viewer-stage { min-height: 220px; max-height: 360px; }
.ws-panel .file-viewer-image { max-height: 320px; }

.ws-deliver {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--ink-50);
  border: 1px solid var(--ink-100);
}
.ws-deliver-title { font-weight: 700; color: var(--ink-900); }
.ws-deliver .btn-primary { width: auto; padding-left: 22px; padding-right: 22px; }

@media (max-width: 640px) {
  .ws-subtabs { grid-template-columns: 1fr; }
  .case-row-actions { flex-wrap: wrap; }
}

/* ---- Technician Patient details: photo gallery + scan list ---- */
.ws-section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ws-section-head h4 { margin: 0; display: flex; align-items: center; gap: 8px; }
.ws-count {
  background: var(--ink-100); color: var(--ink-700);
  border-radius: 999px; padding: 1px 9px; font-size: 14px; font-weight: 700;
}
.ws-section-note { font-size: 14.5px; color: var(--ink-500); }
.photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.photo-tile {
  position: relative;
  padding: 0;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--ink-100);
  cursor: zoom-in;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.25s ease; }
.photo-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.photo-tile:hover img { transform: scale(1.05); }
.photo-tile:focus-visible { outline: 3px solid var(--sky-500); outline-offset: 2px; }
.photo-tile-zoom {
  position: absolute; right: 8px; bottom: 8px;
  width: 28px; height: 28px; border-radius: 50%;
  background: rgba(15, 23, 42, 0.6); color: var(--white);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s ease;
}
.photo-tile-zoom svg { width: 14px; height: 14px; }
.photo-tile:hover .photo-tile-zoom { opacity: 1; }

.scan-list { display: flex; flex-direction: column; gap: 8px; }
.scan-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--ink-100);
  border-radius: 12px;
  background: var(--white);
}
.scan-icon {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--white);
}
.scan-icon svg { width: 20px; height: 20px; }
.scan-icon.kind-model { background: var(--grad-model); }
.scan-icon.kind-pdf { background: var(--grad-doc); }
.scan-icon.kind-other { background: var(--grad-other); }
.scan-main { flex: 1; min-width: 0; }
.scan-name { font-weight: 600; font-size: 15.5px; color: var(--ink-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scan-meta { font-size: 14px; color: var(--ink-500); margin-top: 2px; }
.scan-row .btn { width: auto; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.scan-row .btn svg { width: 14px; height: 14px; }
@media (max-width: 640px) { .photo-gallery { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); } }

/* ---- Patient details: one centered, scrollable box (STL on top, photos below) ---- */
.patient-files-box {
  max-width: 760px;
  margin: 0 auto;
  max-height: 72vh;
  overflow-y: auto;
  padding: 16px 18px;
  border: 1px solid var(--ink-100);
  border-radius: 14px;
  background: var(--ink-50);
  scrollbar-width: thin;
}
.patient-files-box::-webkit-scrollbar { width: 10px; }
.patient-files-box::-webkit-scrollbar-thumb { background: var(--ink-300); border-radius: 999px; border: 2px solid var(--ink-50); }
.patient-files-box #ws-scans { margin-bottom: 22px; }
.photo-stack { display: flex; flex-direction: column; gap: 14px; }
.photo-stack-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--ink-100);
  border-radius: 12px;
  overflow: hidden;
  background: var(--white);
  cursor: zoom-in;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.photo-stack-item:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.photo-stack-item:focus-visible { outline: 3px solid var(--sky-500); outline-offset: 2px; }
.photo-stack-item img { display: block; width: 100%; max-height: 480px; object-fit: contain; background: #0f172a; }
.photo-stack-num {
  position: absolute; left: 10px; top: 10px;
  background: rgba(15, 23, 42, 0.65); color: var(--white);
  font-size: 13px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
}

/* Count badge on a tab (e.g. "New cases 3") */
.tab-count {
  display: inline-block;
  min-width: 20px;
  padding: 1px 7px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--rose-500);
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.tab-count:empty { display: none; }

/* Technician + QA accounts: switch between their two pages */
.role-switch-btn { width: auto; text-decoration: none; margin-right: 6px; white-space: nowrap; }

/* Team table: action buttons stay on one tidy row */
.row-actions { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
input:disabled { background: var(--ink-50); color: var(--ink-500); cursor: not-allowed; }

/* Login: "Keep me signed in" */
.remember-row { display: flex; align-items: flex-start; gap: 8px; margin: 2px 0 14px; font-size: 15px; font-weight: 500; color: var(--ink-700); cursor: pointer; }
.remember-row input { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--teal-600); flex-shrink: 0; }
.remember-hint { color: var(--ink-500); font-size: 13.5px; }

/* ---- Rx: doctor's instructions ---- */
.rx-box {
  border: 1px solid #fcd34d;
  background: #fffbeb;
  border-left: 5px solid var(--amber-500);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 18px;
}
.rx-box-empty { border-color: var(--ink-100); border-left-color: var(--ink-300); background: var(--white); }
.rx-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.rx-badge {
  font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: 700;
  font-size: 17px; color: var(--white); background: var(--amber-500);
  border-radius: 8px; padding: 1px 9px;
}
.rx-box-empty .rx-badge { background: var(--ink-300); }
.rx-title { font-weight: 700; color: var(--ink-900); }
.rx-edit-btn { margin-left: auto; width: auto; }
.rx-body { white-space: pre-wrap; font-size: 16px; line-height: 1.55; color: var(--ink-900); overflow-wrap: anywhere; }
.rx-body textarea { width: 100%; box-sizing: border-box; font: inherit; }
.rx-none { color: var(--ink-500); font-size: 15px; }

/* Compact case line (replaces the big name + timer header) */
.ws-crumb { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ws-crumb .ws-back { margin-bottom: 0; }
.ws-crumb-sep { color: var(--ink-300); }
.ws-crumb-name { font-weight: 700; color: var(--ink-900); font-size: 17px; }

/* ---- Stage buttons + CCM-style notes box ---- */
.stage-btn { width: auto; flex-shrink: 0; white-space: nowrap; }
.stage-row .pill { flex-shrink: 0; }
.stage-note-editor {
  flex-basis: 100%;
  margin: 4px 0 2px 38px;
  padding: 12px 14px;
  background: var(--ink-50);
  border: 1px solid var(--ink-100);
  border-radius: 10px;
}
.stage-note-editor label { display: block; font-weight: 600; font-size: 14.5px; margin-bottom: 6px; color: var(--ink-700); }
.stage-note-optional { font-weight: 400; color: var(--ink-500); }
.stage-note-editor textarea { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; }
.stage-note-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.stage-note-saved {
  margin-top: 6px; padding: 6px 10px;
  background: var(--white); border: 1px solid var(--ink-100); border-radius: 8px;
  font-size: 14.5px; color: var(--ink-700); white-space: pre-wrap; overflow-wrap: anywhere;
}
.stage-note-saved-label { font-weight: 700; color: var(--ink-900); }
@media (max-width: 640px) { .stage-note-editor { margin-left: 0; } }

/* ---- Setup log (CCM-style label : value sheet) ---- */
.setup-log {
  border: 1px solid #bae6fd;
  background: linear-gradient(180deg, #f0f9ff 0%, #ecfeff 100%);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
}
.setup-log-title { font-weight: 700; font-size: 17px; color: var(--ink-900); margin-bottom: 8px; }
.slog-section {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr;
  column-gap: 12px;
  row-gap: 4px;
  padding: 8px 0;
  border-top: 1px dashed #bae6fd;
}
.slog-section:first-of-type { border-top: none; }
.slog-label { text-align: right; font-weight: 700; color: var(--ink-700); font-size: 14.5px; }
.slog-value { color: var(--ink-900); font-size: 14.5px; overflow-wrap: anywhere; }
.slog-notes {
  background: var(--white);
  border: 1px solid var(--ink-100);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 2px 0 4px;
}
.slog-notes-label { font-weight: 700; color: var(--ink-700); }
.slog-empty { color: var(--ink-300); }
.slog-ok { color: var(--green-600); font-weight: 700; }
.slog-bad { color: var(--red-500); font-weight: 700; }
@media (max-width: 640px) {
  .slog-section { grid-template-columns: 1fr; }
  .slog-label { text-align: left; }
}

/* ---- Management: edit / delete case ---- */
.case-tools { display: flex; gap: 8px; flex-wrap: wrap; margin: -4px 0 12px; }
.case-tools .btn { width: auto; }
.ec-file-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.ec-file-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px solid var(--ink-100); border-radius: 10px; background: var(--white); }
.ec-thumb { width: 52px; height: 40px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: var(--ink-100); }
.danger-zone {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 22px; padding: 12px 14px; border: 1px solid #fecaca; background: #fef2f2; border-radius: 10px;
}

/* Management case window: same patient-files box as the technician page */
.patient-files-box-modal { max-width: none; max-height: 60vh; }
/* Keep photo tiles a sensible size while each photo is still loading */
.photo-stack-item img { min-height: 220px; }

/* ---- Files uploaded for a production step (e.g. Cut) ---- */
.stage-upload { margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--ink-100); }
.stage-required { color: var(--red-500); font-weight: 600; }
.stage-upload-btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; margin-top: 6px; }
.stage-upload-btn svg { width: 14px; height: 14px; }
.stage-files { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.stage-file {
  display: flex; align-items: center; gap: 8px;
  background: var(--white); border: 1px solid var(--ink-100); border-radius: 8px; padding: 6px 10px;
}
.stage-file-icon { width: 26px; height: 26px; border-radius: 6px; background: var(--grad-model); color: var(--white); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stage-file-icon svg { width: 15px; height: 15px; }
.stage-file-name { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.stage-file-meta { font-size: 13px; color: var(--ink-500); flex-shrink: 0; }
.stage-file-remove { border: none; background: var(--red-100); color: var(--red-500); width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 16px; line-height: 1; flex-shrink: 0; }
.stage-files-empty { font-size: 14px; color: var(--ink-500); }
.stage-need-file { font-size: 13.5px; color: var(--amber-600, #b45309); margin-right: auto; align-self: center; }
.stage-note-actions { align-items: center; gap: 10px; }
.stage-upload-btn { width: auto !important; }

/* New cases: a case waiting for its next step (e.g. Ready for Stage) */
.case-row-next-step { border-left: 4px solid var(--sky-500); }
.case-row-title .pill { margin-left: 8px; vertical-align: middle; }

/* Stage step: files handed over from the Cut step */
.stage-handover {
  background: #eff6ff; border: 1px solid #bfdbfe; border-left: 4px solid var(--sky-500);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 12px;
}
.stage-handover-title { font-weight: 700; color: #1e3a8a; margin-bottom: 6px; font-size: 14.5px; }
.stage-handover .stage-btn { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.stage-handover .stage-btn svg { width: 14px; height: 14px; }
.stage-handover-note { margin-top: 8px; font-size: 14px; color: var(--ink-700); white-space: pre-wrap; }
.stage-note-editor label.stage-upload-btn { display: inline-flex; width: auto; margin-bottom: 0; }

/* ---- Big upload progress bar with percentage label ---- */
.progress-bar.progress-bar-lg {
  position: relative; height: 30px; border-radius: 8px; margin-top: 12px;
  background: var(--ink-100); border: 1px solid var(--ink-200, #d9dee5);
}
.progress-bar.progress-bar-lg .progress-bar-fill {
  background: linear-gradient(90deg, var(--teal-500), #22c3a6);
  background-size: 40px 40px;
  background-image: linear-gradient(135deg, rgba(255,255,255,.18) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.18) 50%, rgba(255,255,255,.18) 75%, transparent 75%), linear-gradient(90deg, var(--teal-500), #22c3a6);
  animation: progress-stripes 1s linear infinite;
  transition: width 0.3s ease;
}
.progress-bar.progress-bar-lg .progress-bar-fill.done { animation: none; }
.progress-bar-label {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: var(--ink-900, #1f2933); white-space: nowrap;
  text-shadow: 0 0 3px rgba(255,255,255,.9); pointer-events: none; padding: 0 8px; overflow: hidden;
}
@keyframes progress-stripes { from { background-position: 40px 0, 0 0; } to { background-position: 0 0, 0 0; } }

/* Doctor details are Management-only (hidden for the Manager role) */
.manager-only-inline { display: none; }
body.is-manager .mgmt-only-inline { display: none; }
body.is-manager .manager-only-inline { display: inline; }
body.is-manager .mgmt-only { display: none !important; }
.stage-note-editor textarea.input-error { border-color: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.15); }

/* ---- One-by-one completed-file uploads ---- */
.draft-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; max-height: 340px; overflow-y: auto; }
.draft-row { border: 1px solid var(--ink-100); border-radius: 10px; padding: 9px 12px; background: #fff; display: flex; flex-direction: column; gap: 6px; }
.draft-row.done { flex-direction: row; align-items: center; gap: 10px; background: #f0fdf9; border-color: #b7ebdc; }
.draft-row-top { display: flex; align-items: center; gap: 10px; }
.draft-status { width: 24px; height: 24px; flex: none; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; background: var(--ink-100); color: var(--ink-700, #334155); }
.draft-status.ok { background: var(--teal-500); color: #fff; }
.draft-row.error .draft-status { background: #fee2e2; color: #b91c1c; }
.draft-row.uploading .draft-status { background: #dbeafe; color: #1d4ed8; }
.draft-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.draft-size { color: var(--ink-500, #64748b); font-size: 14px; white-space: nowrap; }
.draft-remove { background: none; border: none; color: #dc2626; font-weight: 600; cursor: pointer; padding: 4px 6px; font-size: 14px; }
.draft-remove:hover { text-decoration: underline; }
.draft-row .progress-bar { margin-top: 2px; }
.draft-note { font-size: 13px; color: var(--ink-500, #64748b); padding-left: 34px; }
.draft-note.err { color: #b91c1c; }

/* ---- Notification bell ---- */
.notif-wrap { position: relative; display: inline-flex; margin-right: 10px; }
.notif-bell { position: relative; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--ink-100); background: #fff; color: var(--ink-700, #334155); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s; }
.notif-bell:hover { background: var(--ink-50, #f8fafc); color: var(--teal-500); }
.notif-badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #ef4444; color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; border: 2px solid #fff; }
.notif-badge.hidden { display: none; }
.notif-panel { position: absolute; top: 50px; right: 0; width: 380px; max-width: calc(100vw - 24px); background: #fff; border: 1px solid var(--ink-100); border-radius: 14px; box-shadow: 0 18px 40px rgba(15,23,42,.18); z-index: 1000; overflow: hidden; }
.notif-panel.hidden { display: none; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--ink-100); font-size: 16px; }
.notif-markall { background: none; border: none; color: var(--teal-500); font-weight: 600; cursor: pointer; font-size: 14px; }
.notif-list { max-height: 440px; overflow-y: auto; }
.notif-empty { padding: 26px 14px; text-align: center; color: var(--ink-500, #64748b); }
.notif-item { width: 100%; display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 12px 14px; border: none; border-bottom: 1px solid var(--ink-100); background: #fff; cursor: pointer; font: inherit; }
.notif-item:hover { background: var(--ink-50, #f8fafc); }
.notif-item.unread { background: #f0fdfa; }
.notif-item.unread:hover { background: #e2faf5; }
.notif-icon { font-size: 18px; line-height: 1.3; flex: none; }
.notif-body { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.notif-msg { font-size: 14.5px; color: var(--ink-900, #1f2933); overflow-wrap: anywhere; }
.notif-item.unread .notif-msg { font-weight: 600; }
.notif-time { font-size: 12.5px; color: var(--ink-500, #64748b); }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--teal-500); flex: none; margin-top: 6px; }
@media (max-width: 640px) { .notif-panel { position: fixed; top: 64px; right: 12px; left: 12px; width: auto; } }

/* Doctor: withdraw a pending case */
.withdraw-box { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid #fecaca; background: #fef2f2; border-radius: 10px; }
.doc-files-edit .doc-files-head { display: flex; flex-direction: column; gap: 2px; }
.doc-files-edit .draft-name a { color: inherit; text-decoration: underline; }

/* New case tab: single upload card (Drive import retired) */
.new-case-single { max-width: 760px; margin: 0 auto; }

/* ---- Doctor portal ---- */
.doc-stats .doc-stat { text-align: left; cursor: pointer; border: none; font: inherit; transition: transform .12s, box-shadow .12s; }
.doc-stats .doc-stat:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(15,23,42,.10); }
.doc-stats .doc-stat.selected { outline: 2px solid var(--teal-500); }
.doc-stats .doc-stat-review { border-top-color: #f59e0b !important; }
.doc-stats .doc-stat-review .stat-value { color: #b45309 !important; }
.doc-stats .doc-stat-progress { border-top-color: var(--sky-500) !important; }
.doc-stats .doc-stat-progress .stat-value { color: #0369a1 !important; }
.doc-stats .doc-stat-waiting { border-top-color: #a78bfa !important; }
.doc-stats .doc-stat-waiting .stat-value { color: #6d28d9 !important; }
.doc-stats .doc-stat-approved { border-top-color: #22c55e !important; }
.doc-stats .doc-stat-approved .stat-value { color: #15803d !important; }
.doc-filter-note { margin: -4px 0 10px; color: var(--ink-500, #64748b); font-size: 14.5px; }
.doc-case-row { gap: 12px; }
.doc-case-row.needs-review { background: #fffbeb; border-color: #fcd34d; }
.pill-review { background: #fef3c7; color: #92400e; }
.doc-new-card { max-width: 760px; margin: 0 auto; }
textarea.input-error, input.input-error { border-color: #ef4444 !important; box-shadow: 0 0 0 3px rgba(239,68,68,.15); }

/* Stars */
.stars { color: #f59e0b; letter-spacing: 1px; font-size: 17px; white-space: nowrap; }
.stars .stars-off { color: #d6dbe3; }

/* Doctor review form (doctor side) */
.doctor-review-form { margin-top: 14px; padding: 14px; border: 1px solid #fcd34d; background: #fffbeb; border-radius: 12px; }
.doctor-review-title { font-weight: 700; margin-bottom: 8px; }
.star-picker { display: flex; align-items: center; gap: 4px; margin-bottom: 10px; }
.star-btn { background: none; border: none; cursor: pointer; font-size: 32px; line-height: 1; color: #d6dbe3; padding: 0 2px; transition: transform .1s, color .1s; }
.star-btn:hover { transform: scale(1.12); }
.star-btn.on { color: #f59e0b; }
.star-label { margin-left: 8px; color: var(--ink-500, #64748b); font-weight: 600; }
.doctor-review-form textarea { width: 100%; box-sizing: border-box; }

/* Doctor review shown on a version (all sides) */
.doctor-review-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; border: 1px solid; }
.doctor-review-note.ok { background: #f0fdf4; border-color: #bbf7d0; }
.doctor-review-note.bad { background: #fef2f2; border-color: #fecaca; }
.doctor-review-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doctor-review-comment { margin-top: 6px; font-style: italic; color: var(--ink-700, #334155); }
.nick-chip { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #eef2ff; color: #3730a3; font-weight: 600; font-size: 14px; }
.nick-missing { color: #b45309; font-size: 13.5px; font-style: italic; }
.doc-case-row .btn { flex: 0 0 auto; width: auto; white-space: nowrap; }
.doc-case-row .pill { flex: 0 0 auto; white-space: nowrap; }
.doc-case-row .case-row-main { flex: 1; min-width: 0; }

/* Doctor: case progress tracker */
.doc-progress { display: flex; align-items: center; gap: 6px; margin: 6px 0 16px; padding: 12px 14px; background: var(--ink-50, #f8fafc); border: 1px solid var(--ink-100); border-radius: 12px; overflow-x: auto; }
.doc-step { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 76px; }
.doc-step-dot { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; background: #e5e7eb; color: #6b7280; }
.doc-step.done .doc-step-dot { background: var(--teal-500); color: #fff; }
.doc-step.current .doc-step-dot { background: #f59e0b; color: #fff; box-shadow: 0 0 0 4px rgba(245,158,11,.2); }
.doc-step-label { font-size: 12.5px; color: var(--ink-500, #64748b); text-align: center; white-space: nowrap; }
.doc-step.current .doc-step-label { color: var(--ink-900, #1f2933); font-weight: 700; }
.doc-step-line { flex: 1; height: 2px; background: #e5e7eb; min-width: 14px; margin-bottom: 18px; }
.doc-older-setups { margin-top: 12px; border: 1px solid var(--ink-100); border-radius: 12px; padding: 10px 14px; background: var(--ink-50, #f8fafc); }
.doc-older-setups > summary { cursor: pointer; font-weight: 700; color: var(--ink-700, #334155); }
.doc-older-setups[open] > summary { margin-bottom: 10px; }

/* ---- Doctor ratings (technician History, QA Reviewed, Management) ---- */
.muted { color: var(--ink-500); font-size: 13px; }
.pill-changes { background: var(--rose-100); color: #be123c; }
.row-stars .stars { font-size: 15px; }
.row-waiting { font-size: 13px; color: var(--ink-500); white-space: nowrap; }
.case-row-side { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.stars-avg { position: relative; display: inline-block; font-size: 20px; letter-spacing: 2px; line-height: 1; white-space: nowrap; }
.stars-avg-off { color: #d6dbe3; }
.stars-avg-on { position: absolute; left: 0; top: 0; overflow: hidden; color: #f59e0b; }
.stars-avg.sm { font-size: 14px; letter-spacing: 1px; }
.rating-summary { display: grid; grid-template-columns: 150px minmax(180px, 1fr) minmax(240px, 1.2fr); gap: 20px; align-items: center; }
.rating-score { text-align: center; padding: 8px 0; }
.rating-big { font-size: 44px; font-weight: 700; color: var(--ink-900); line-height: 1.05; margin-bottom: 6px; }
.rating-score .muted { margin-top: 6px; }
.rating-bars { display: flex; flex-direction: column; gap: 6px; }
.rating-bar-row { display: grid; grid-template-columns: 34px 1fr 26px; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-700); }
.rating-bar { height: 8px; background: var(--ink-100); border-radius: 99px; overflow: hidden; }
.rating-bar > span { display: block; height: 100%; background: #f59e0b; border-radius: 99px; }
.rating-bar-count { text-align: right; color: var(--ink-500); }
.rating-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rating-tile { background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: var(--radius); padding: 10px 12px; }
.rating-tile-value { font-size: 20px; font-weight: 700; color: var(--ink-900); }
.rating-tile-label { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.rating-tile-warn .rating-tile-value { color: #be123c; }
.rating-empty { display: flex; align-items: center; gap: 14px; padding: 6px 2px; }
.rating-empty-star { font-size: 30px; color: #d6dbe3; }
.feedback-title { margin: 20px 0 8px; font-size: 14px; color: var(--ink-700); }
.feedback-list { display: flex; flex-direction: column; border: 1px solid var(--ink-100); border-radius: var(--radius); overflow: hidden; }
.feedback-item { padding: 10px 14px; border-bottom: 1px solid var(--ink-100); background: var(--white); }
.feedback-item:last-child { border-bottom: 0; }
.feedback-clickable { cursor: pointer; }
.feedback-clickable:hover { background: var(--ink-50); }
.feedback-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.feedback-head .stars { font-size: 15px; }
.feedback-meta { font-size: 13px; color: var(--ink-500); }
.feedback-meta strong { color: var(--ink-700); font-weight: 600; }
.feedback-text { margin-top: 4px; color: var(--ink-900); font-size: 14px; }
.rating-cell { white-space: nowrap; }
.rating-cell .rating-num { font-weight: 600; color: var(--ink-900); margin-left: 4px; }
.rating-cell .muted { font-size: 12px; }
.rating-cell .rating-changes { display: block; font-size: 12px; color: #be123c; }
@media (max-width: 860px) {
  .rating-summary { grid-template-columns: 1fr; }
  .rating-score { display: flex; align-items: center; gap: 12px; text-align: left; }
  .rating-big { margin: 0; }
}

/* Phones: the top bar wraps instead of pushing the page sideways. */
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .topbar-right { flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-left: auto; font-size: 14px; }
  .topbar-identity-sub { display: none; }
}

/* =====================================================================
   Brand: charcoal & gold (logo option A)
   ===================================================================== */
:root {
  --charcoal: #16181d;
  --charcoal-2: #2a2c32;
  --gold: #d4a72c;
  --gold-deep: #a8801a;
  --gold-text: #8c6b14;
}
html, body {
  background: linear-gradient(180deg, #f7f5f0 0%, #efece5 100%);
  background-attachment: fixed;
}
.brand-logo { height: 44px; width: auto; display: block; }
@media (max-width: 640px) { .brand-logo { height: 34px; } }
.tab-btn.active { color: var(--charcoal); border-image: linear-gradient(90deg, var(--gold-deep), var(--gold)) 1; }
.btn-primary {
  background: var(--charcoal);
  color: var(--white);
  box-shadow: inset 0 -2px 0 var(--gold), 0 2px 6px rgba(22, 24, 29, 0.18);
}
.btn-primary:hover { filter: none; background: var(--charcoal-2); box-shadow: inset 0 -2px 0 var(--gold), 0 4px 10px rgba(22, 24, 29, 0.24); }
.btn-outline { color: var(--charcoal); border-color: var(--gold-deep); }
.topbar-avatar-fallback, .account-avatar-fallback { background: var(--charcoal); color: var(--gold); }
input:focus, select:focus, textarea:focus { outline-color: var(--gold-deep); border-color: var(--gold-deep); }
.notif-bell:hover { color: var(--gold-text); }
.notif-markall { color: var(--gold-text); }
.notif-item.unread { background: var(--teal-50); }
.draft-status.ok { background: var(--gold-text); }
.file-viewer-nav-btn:hover { background: var(--charcoal); }
.image-preview-nav:hover { background: var(--gold-deep); }
.progress-bar.progress-bar-lg .progress-bar-fill {
  background-image: linear-gradient(135deg, rgba(255,255,255,.18) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.18) 50%, rgba(255,255,255,.18) 75%, transparent 75%), linear-gradient(90deg, var(--gold-deep), var(--gold));
}
.doc-step.done .doc-step-dot { background: var(--gold-text); color: #fff; }
.doc-step.current .doc-step-dot { background: var(--charcoal); color: var(--gold); box-shadow: 0 0 0 4px rgba(212, 167, 44, 0.3); }

/* Sign-in page: warm ivory with the logo above the card */
body.auth-page { background: linear-gradient(180deg, #fbfaf6 0%, #f1ede4 100%); background-attachment: fixed; }
.auth-page .centered-shell { flex-direction: column; gap: 28px; }
.auth-page .centered-shell::before {
  background: radial-gradient(ellipse at 50% 0%, rgba(212, 167, 44, 0.10), transparent 55%);
  filter: none;
}
.auth-page .auth-card { box-shadow: 0 1px 2px rgba(22, 24, 29, 0.06), 0 12px 32px rgba(22, 24, 29, 0.08); }
.auth-brand { width: 320px; max-width: 82vw; height: auto; display: block; }
.auth-page .auth-card { border-top: 3px solid var(--gold); }
.auth-title { text-align: center; font-size: 22px; font-weight: 700; color: var(--charcoal); margin-bottom: 4px; }

/* ---- Doctors tab PIN ---- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.doctors-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.doctors-actions .btn { width: auto; }
.pin-gate { display: flex; justify-content: center; padding: 18px 0 8px; }
.pin-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 26px 24px; border: 1px solid var(--ink-100); border-radius: 14px; background: var(--ink-50); }
.pin-card-wide { max-width: 420px; text-align: left; align-items: stretch; }
.pin-card-wide h3, .pin-card-wide .pin-icon { align-self: center; }
.pin-card h3 { margin: 2px 0 0; }
.pin-card .help-text { margin: 0; }
.pin-icon { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--charcoal); color: var(--gold); }
input.pin-input { width: 170px; text-align: center; font-size: 26px; letter-spacing: 0.5em; padding: 10px 0 10px 0.5em; font-variant-numeric: tabular-nums; }
.pin-card-wide input.pin-input { width: 100%; }
.pin-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pin-card .btn-primary { width: 100%; }
.pin-link { font-size: 14px; }
.pin-card .error-text:empty { display: none; }

/* ---- Automatic sign-out ---- */
.idle-warning { position: fixed; inset: 0; background: rgba(17, 18, 20, 0.45); display: none; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.idle-warning.open { display: flex; }
.idle-warning-card { background: var(--white); border-radius: 14px; padding: 24px; max-width: 380px; width: 100%; box-shadow: var(--shadow-md); border-top: 3px solid var(--gold); text-align: center; }
.idle-warning-card strong { font-size: 19px; display: block; margin-bottom: 6px; }
.idle-warning-card p { margin: 0 0 16px; color: var(--ink-700); }
.screenlock-banner { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 900; display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; background: var(--white); border: 1px solid var(--ink-100); border-left: 4px solid var(--gold); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow-md); max-width: calc(100vw - 32px); font-size: 15px; }
.screenlock-actions { display: flex; gap: 8px; }
.screenlock-actions .btn { width: auto; }
.signed-out-note { background: var(--teal-50); border: 1px solid var(--teal-100); color: var(--ink-700); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin: -8px 0 18px; text-align: center; }
.security-setting-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.security-setting-row label { margin: 0; }
.security-setting-row .btn { width: auto; }

/* ---- Teams ---- */
.team-chip { display: inline-block; vertical-align: middle; padding: 2px 10px; border-radius: 999px; background: #f6efd9; color: var(--gold-text); border: 1px solid #ecdcae; font-weight: 600; font-size: 13px; line-height: 1.5; white-space: nowrap; }
.team-chip-pool { background: var(--ink-50); color: var(--ink-500); border-color: var(--ink-100); font-weight: 500; }
.case-row-title .team-chip { margin-left: 6px; font-size: 12px; }
.help-text .team-chip { margin-right: 6px; }
.team-notice { border-left: 4px solid var(--gold); margin-bottom: 16px; display: flex; flex-direction: column; gap: 4px; }
.team-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; color: var(--ink-700); font-size: 15px; }
.cell-sub { color: var(--ink-500); font-size: 12.5px; margin-top: 2px; }
.row-actions .btn { width: auto; }

/* ---- Performance ---- */
.perf-header { flex-wrap: wrap; gap: 12px; }
.perf-filters { display: flex; gap: 8px; flex-wrap: wrap; }
.perf-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 4px 0 16px; }
.perf-card { border: 1px solid var(--ink-100); border-radius: 12px; padding: 12px 14px; background: var(--ink-50); min-width: 0; }
.perf-card-value { font-size: 20px; font-weight: 700; color: var(--charcoal); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.perf-card-label { font-size: 13px; color: var(--ink-500); margin-top: 2px; }
.perf-table td { vertical-align: top; }
.perf-help { margin-top: 12px; line-height: 1.6; }
.best-badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--charcoal); color: var(--gold); font-size: 12px; font-weight: 700; vertical-align: middle; }
.verdict { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.verdict-top { background: #e7f6ec; color: #166534; }
.verdict-good { background: #eef7e6; color: #3f6212; }
.verdict-avg { background: #fdf5e0; color: #8c6b14; }
.verdict-low { background: #fdecec; color: #b42318; }
.verdict-none { background: var(--ink-50); color: var(--ink-500); }
@media (max-width: 640px) {
  .perf-filters { width: 100%; }
  .perf-filters select { flex: 1; }
}

/* ---- Phone widths: tabs and wide tables scroll inside the page, never the page itself ---- */
.scroll-table-wrap { overflow-x: auto; }
.grid-2 > * { min-width: 0; }
@media (max-width: 760px) {
  .tabs { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { flex: 0 0 auto; white-space: nowrap; }
  .card .team-table, .card .history-table { display: block; overflow-x: auto; }
  .card-header { flex-wrap: wrap; gap: 10px; }
}
.card-header > .btn { width: auto; flex-shrink: 0; white-space: nowrap; }
@media (max-width: 760px) { .perf-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stage-file-locked { color: var(--ink-500); cursor: default; }
.stage-file-locked::after { content: " \1F512"; font-size: 12px; }

/* ---- Email alerts (Admin) ---- */
.ea-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.ea-block { min-width: 0; }
.ea-h { font-size: 15px; margin: 0 0 10px; color: var(--charcoal); }
.ea-list { display: flex; flex-direction: column; gap: 6px; }
.ea-recipient { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: 8px; padding: 6px 10px; font-size: 15px; overflow-wrap: anywhere; }
.ea-remove { border: none; background: transparent; font-size: 20px; line-height: 1; color: var(--ink-500); cursor: pointer; padding: 0 4px; }
.ea-remove:hover { color: #b42318; }
.ea-add { display: flex; gap: 8px; margin-top: 8px; }
.ea-add input { flex: 1; min-width: 0; }
.ea-add .btn { width: auto; }
.ea-radio { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 4px 0; cursor: pointer; }
.ea-radio input { width: auto; }
.ea-toggle { display: flex; align-items: center; gap: 10px; margin: 16px 0 6px; cursor: pointer; }
.ea-toggle input { width: auto; }
.ea-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 8px; }
.ea-actions .help-text { flex: 1; min-width: 200px; }
.ea-actions .btn { width: auto; }
.ea-bad { color: #b42318; }
@media (max-width: 760px) { .ea-grid { grid-template-columns: 1fr; } }
.auth-switch { text-align: center; margin: 16px 0 0; font-size: 14.5px; color: var(--ink-500); }
.pullback-box { margin-top: 14px; border: 1px solid var(--ink-100); border-radius: 10px; padding: 10px 14px; background: var(--ink-50); }
.pullback-box summary { cursor: pointer; font-weight: 600; color: #b42318; }
/* A pop-up window always wins over the screen-lock banner (it could cover Save). */
body:has(.modal-backdrop:not(.hidden)) .screenlock-banner { display: none; }
/* Pull back: what to redo */
.pb-scope { display: flex; flex-direction: column; gap: 6px; }
.pb-scope label { display: flex; gap: 8px; align-items: baseline; font-weight: 400; cursor: pointer; margin: 0; }
.redo-box { background: #fff7ed; border: 1px solid #fed7aa; border-left: 4px solid #ea580c; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.redo-title { color: #9a3412; }
.redo-reason { margin-top: 4px; color: var(--ink-700, #334155); }
.redo-help { margin-top: 4px; font-size: 14px; color: var(--ink-500); }
.redo-inline { color: #9a3412; }
.replaced-files { margin-top: 8px; font-size: 14px; }
.replaced-files summary { cursor: pointer; color: var(--ink-500); }
.replaced-files .stage-file { opacity: .75; }
/* Software */
.sw-pill { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; vertical-align: middle; }
td .sw-pill { margin-top: 4px; }
.sw-checks { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.sw-check { display: inline-flex; align-items: center; gap: 5px; font-weight: 400; font-size: 14.5px; margin: 0; cursor: pointer; white-space: nowrap; }
.software-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.software-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.software-row input { max-width: 220px; }
.software-add { display: flex; gap: 8px; max-width: 420px; }
/* Clarification questions */
.questions-panel { margin: 14px 0; padding: 12px 14px; border: 1px solid var(--ink-100); border-radius: 12px; background: #f8fafc; }
.q-item { background: var(--white); border: 1px solid var(--ink-100); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.q-review .q-item, .q-item.q-review { border-left: 4px solid #f59e0b; }
.q-item.q-sent { border-left: 4px solid #3b82f6; }
.q-item.q-answered { border-left: 4px solid #16a34a; }
.q-item.q-declined { opacity: .8; }
.q-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.q-meta { font-size: 13.5px; color: var(--ink-500); }
.q-text { margin-top: 6px; white-space: pre-wrap; }
.q-note { margin-top: 6px; font-size: 14px; color: var(--ink-500); font-style: italic; }
.q-answer { margin-top: 8px; padding: 8px 10px; background: #f0fdf4; border-radius: 8px; white-space: pre-wrap; }
.q-answer-label { font-size: 13px; font-weight: 600; color: #166534; margin-bottom: 2px; }
.q-review, .q-record, .q-ask { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.q-record summary { cursor: pointer; color: var(--ink-500); font-size: 14px; }
.q-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.q-actions .help-text { flex: 1; min-width: 200px; }
.doc-questions { margin: 12px 0; display: flex; flex-direction: column; gap: 10px; }
.doc-question { border: 1px solid #bfdbfe; border-left: 4px solid #3b82f6; background: #eff6ff; border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.doc-question.answered { border-color: #bbf7d0; border-left-color: #16a34a; background: #f0fdf4; }
.doc-question-head { font-weight: 600; }
.doc-question-text { white-space: pre-wrap; }
.doc-question .btn { align-self: flex-end; }
/* Due times + Exocad */
.due-chip { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; vertical-align: middle; white-space: nowrap; }
.due-chip.due-soon { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.due-chip.due-late { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.exo-pill { display: inline-block; font-size: 12.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #ecfeff; color: #0e7490; border: 1px solid #a5f3fc; vertical-align: middle; }
.exo-order { border: 1px solid #a5f3fc; border-left: 4px solid #0891b2; background: #f0fdff; border-radius: 10px; padding: 10px 14px; margin: 12px 0; }
.exo-order-title { font-weight: 700; color: #0e7490; margin-bottom: 6px; }
.exo-row { display: flex; gap: 10px; padding: 2px 0; }
.exo-row span { min-width: 80px; color: var(--ink-500); }
.exo-upload { border: 1px dashed var(--ink-200, #cbd5e1); border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.exo-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 640px) { .exo-fields { grid-template-columns: 1fr; } }
.type-switch { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.type-switch label { flex: 1; min-width: 180px; display: flex; gap: 8px; align-items: center; border: 1px solid var(--ink-100); border-radius: 10px; padding: 10px 12px; cursor: pointer; margin: 0; font-weight: 600; }
.type-switch label:has(input:checked) { border-color: var(--gold, #d4a72c); background: #fffbeb; }
#case-modal { max-width: 800px; }
.work-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 14px; } @media (max-width: 760px) { .work-grid { grid-template-columns: 1fr; } }
/* Messages ("Ask us") */
.tabs .ask-us-btn { margin-left: auto; align-self: center; }
.msg-thread { border: 1px solid var(--ink-100); border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; background: var(--white); }
.msg-thread.msg-unread { border-left: 4px solid #3b82f6; }
.msg-thread-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.msg-post { border-radius: 10px; padding: 8px 12px; margin: 6px 0; max-width: 88%; }
.msg-post.msg-mine { background: #f0fdf4; margin-left: auto; }
.msg-post.msg-theirs { background: #eff6ff; }
.msg-meta { font-size: 13px; color: var(--ink-500); margin-bottom: 2px; }
.msg-body { white-space: pre-wrap; }
.msg-reply { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.msg-reply > .btn { align-self: flex-end; }
.msg-reply .q-actions .btn { width: auto; }
#panel-messages .card-header .ea-toggle { white-space: nowrap; flex-shrink: 0; }
/* Server storage */
.storage-bar { height: 14px; border-radius: 999px; background: var(--ink-100); overflow: hidden; }
.storage-fill { height: 100%; border-radius: 999px; background: #16a34a; }
.storage-watch .storage-fill { background: #f59e0b; }
.storage-warn .storage-fill, .storage-critical .storage-fill { background: #dc2626; }
.storage-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 14.5px; }
.storage-banner { background: #fef2f2; border: 1px solid #fecaca; border-left: 4px solid #dc2626; color: #991b1b; border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; }
/* Automatic translation */
.tr-note { display: block; margin-top: 4px; font-size: 12.5px; color: var(--ink-500); font-style: normal; }
.tr-note a { color: inherit; text-decoration: underline; }
/* Translator choice (Admin → Automatic translation) */
.tr-providers .ea-toggle { align-items: flex-start; margin: 8px 0; font-weight: 400; }
.tr-providers .ea-toggle input { margin-top: 3px; }
.tr-providers code { font-size: 0.85em; }
/* Edge/IE add their own "show password" eye inside password boxes; we have
   our own toggle, so hide the browser's to avoid two eyes. */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none; }
