/* =============================================================================
   Patient Imaging Portal — MedSyntra-inspired visual language
   Aesthetic: quiet, trustworthy, dense with useful information.
   Reference points: Linear, Notion, Stripe dashboard. Not a marketing page.
   Light default with dark-mode toggle (persists via [data-theme] on <html>).
   All existing class names from the prior stylesheet are preserved so
   templates render without structural rewrites.
   ============================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── Design tokens ───────────────────────────────────────────────────────── */
:root {
  /* Surfaces — light theme (default) */
  --bg:            #F7F8FA;
  --surface:       #FFFFFF;
  --surface-2:     #F4F6F9;
  --surface-3:     #EEF1F5;
  --hover:         #F4F6F9;

  /* Text */
  --text:          #0B1B2B;   /* primary ink */
  --text-2:        #334155;   /* secondary */
  --muted:         #64748B;   /* tertiary */
  --faint:         #94A3B8;   /* labels, hints */

  /* Borders */
  --border:        #E4E8EE;
  --border-strong: #CBD5E1;
  --divider:       #EEF1F5;

  /* Brand & accent — restrained, single-accent rule from the brief */
  --brand:         #0B1B2B;   /* deep ink-navy, the wordmark colour */
  --accent:        #0EA5A4;   /* muted teal — used sparingly */
  --accent-hover:  #0B8786;
  --accent-soft:   rgba(14, 165, 164, 0.08);
  --accent-ring:   rgba(14, 165, 164, 0.22);
  --focus-ring:    rgba(14, 165, 164, 0.32);

  /* Semantic — used sparingly, never decoratively */
  --ok:            #15803D;
  --ok-bg:         #ECFDF5;
  --ok-border:     #BBF7D0;

  --warn:          #B45309;
  --warn-bg:       #FFFBEB;
  --warn-border:   #FDE68A;

  --err:           #B91C1C;
  --err-bg:        #FEF2F2;
  --err-border:    #FECACA;

  --info:          #1D4ED8;
  --info-bg:       #EFF6FF;
  --info-border:   #BFDBFE;

  /* Geometry */
  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-pill:   999px;

  /* Elevation — subtle, single-layer; no glamour shadows */
  --shadow-sm:     0 1px 2px rgba(11, 27, 43, 0.04), 0 1px 0 rgba(11, 27, 43, 0.02);
  --shadow:        0 1px 3px rgba(11, 27, 43, 0.06), 0 1px 2px rgba(11, 27, 43, 0.04);
  --shadow-lg:     0 4px 16px rgba(11, 27, 43, 0.08);

  /* Type */
  --font-sans:     'Geist', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono:     'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Layout */
  --sidebar-w:     232px;
  --header-h:      56px;
  --content-max:   1480px;
}

/* ── Dark theme ──────────────────────────────────────────────────────────── */
:root[data-theme="dark"] {
  --bg:            #0B121C;
  --surface:       #111A26;
  --surface-2:     #0F1721;
  --surface-3:     #1A2433;
  --hover:         #18222F;

  --text:          #E6ECF2;
  --text-2:        #C2CDD8;
  --muted:         #8A97A6;
  --faint:         #5C6B7C;

  --border:        #1F2A38;
  --border-strong: #2A3645;
  --divider:       #1A2433;

  --brand:         #E6ECF2;     /* invert wordmark in dark */
  --accent:        #2DD4D2;
  --accent-hover:  #4DE4E2;
  --accent-soft:   rgba(45, 212, 210, 0.10);
  --accent-ring:   rgba(45, 212, 210, 0.28);
  --focus-ring:    rgba(45, 212, 210, 0.38);

  --ok:            #4ADE80;
  --ok-bg:         rgba(34, 197, 94, 0.10);
  --ok-border:     rgba(34, 197, 94, 0.30);

  --warn:          #FBBF24;
  --warn-bg:       rgba(245, 158, 11, 0.10);
  --warn-border:   rgba(245, 158, 11, 0.30);

  --err:           #F87171;
  --err-bg:        rgba(239, 68, 68, 0.10);
  --err-border:    rgba(239, 68, 68, 0.30);

  --info:          #60A5FA;
  --info-bg:       rgba(59, 130, 246, 0.10);
  --info-border:   rgba(59, 130, 246, 0.30);

  --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.40);
  --shadow:        0 1px 3px rgba(0, 0, 0, 0.50), 0 1px 2px rgba(0, 0, 0, 0.30);
  --shadow-lg:     0 6px 24px rgba(0, 0, 0, 0.55);
}

/* ── Reset / base ────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }
*::selection { background: var(--accent-soft); color: var(--text); }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01", "ss03";
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
h1 { font-size: 22px; line-height: 1.2; margin: 0; }
h2 { font-size: 16px; line-height: 1.3; margin: 0; }
h3 { font-size: 14px; line-height: 1.3; margin: 0; }

/* Identifiers, IDs, UIDs, accession numbers — mono with subtle treatment */
.mono, code, kbd, .uid-cell, .patient-id, [data-mono] {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: -0.01em;
}

/* ── App shell: sidebar + main ───────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.app-no-shell { /* used by login + share landing — centred single card */
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 80% -10%, var(--accent-soft), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, var(--accent-soft), transparent 60%),
    var(--bg);
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
  height: var(--header-h);
}
.sidebar-brand img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.sidebar-brand-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.sidebar-brand-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.sidebar-section {
  padding: 14px 10px 6px 10px;
}
.sidebar-section-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 8px 6px 8px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 8px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  border-radius: var(--radius-sm);
  transition: background 80ms ease, color 80ms ease;
}
.sidebar-link:hover {
  background: var(--hover);
  color: var(--text);
  text-decoration: none;
}
.sidebar-link.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 600;
}
:root[data-theme="dark"] .sidebar-link.active {
  color: #67E8E8;
  background: rgba(45, 212, 210, 0.16);
}
.sidebar-link.active::before {
  content: "";
  width: 2px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
  margin-right: -2px;
  margin-left: -10px;
  margin-block: 0;
}
.sidebar-link svg { width: 16px; height: 16px; flex: 0 0 16px; opacity: 0.8; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex: 0 0 28px;
}
.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
.user-role {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-actions {
  display: flex;
  gap: 6px;
}
.icon-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: background 80ms ease, color 80ms ease, border-color 80ms ease;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
  border-color: var(--border-strong);
}
.icon-btn svg { width: 14px; height: 14px; }

/* ── Main column ─────────────────────────────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar-thin {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--header-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: saturate(140%) blur(6px);
}
.crumbs {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.crumbs strong { color: var(--text); font-weight: 600; }
.crumbs-sep {
  color: var(--faint);
  font-size: 12px;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.page-shell {
  padding: 24px 24px 48px 24px;
  max-width: var(--content-max);
  width: 100%;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 18px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 { margin: 0 0 4px 0; }
.page-subtitle { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.detail-card { max-width: 920px; }
.narrow-card { max-width: 440px; width: 100%; }

.section-title {
  margin: 0 0 14px 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}
.empty-state {
  padding: 24px 18px;
  color: var(--muted);
  font-size: 13px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 80ms ease, border-color 80ms ease, color 80ms ease, box-shadow 80ms ease;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.btn:hover { text-decoration: none; }

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--hover); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--hover); color: var(--text); }

.btn-danger {
  background: var(--surface);
  color: var(--err);
  border-color: var(--err-border);
}
.btn-danger:hover { background: var(--err-bg); }

.btn-full { width: 100%; }
.btn-sm   { padding: 5px 9px; font-size: 12.5px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form { display: grid; gap: 14px; }

label {
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
}

input[type=text],
input[type=password],
input[type=number],
input[type=search],
input[type=email],
input:not([type]),
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 80ms ease, box-shadow 80ms ease, background 80ms ease;
  font-variant-numeric: tabular-nums;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
}
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A97A6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
}

/* ── Alerts / flash ──────────────────────────────────────────────────────── */
.alert {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert::before {
  content: "";
  width: 3px;
  align-self: stretch;
  border-radius: 2px;
  flex: 0 0 3px;
}
.alert-success, .alert-success::before { background-color: var(--ok-bg); border-color: var(--ok-border); }
.alert-success { color: var(--ok); }
.alert-success::before { background: var(--ok); }
.alert-error, .error, .alert-error::before { background-color: var(--err-bg); border-color: var(--err-border); }
.alert-error, .error { color: var(--err); }
.alert-error::before { background: var(--err); }
.alert-info, .alert-info::before { background-color: var(--info-bg); border-color: var(--info-border); }
.alert-info { color: var(--info); }
.alert-info::before { background: var(--info); }

.muted { color: var(--muted); }

/* ── Tables ──────────────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.data-table thead th {
  text-align: left;
  padding: 9px 12px;
  background: var(--surface-2);
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.data-table tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--hover); }
.data-table tbody tr:hover .patient-id { color: var(--text); }

/* Specific table treatments preserved */
.admin-study-table {
  width: 100%;
  table-layout: auto;
  border-collapse: collapse;
}
.admin-study-table th,
.admin-study-table td {
  border-right: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
  padding: 11px 12px;
  white-space: nowrap;
}
.admin-study-table th:last-child,
.admin-study-table td:last-child { border-right: none; }
.admin-study-table tbody tr:last-child td { border-bottom: none; }
.admin-study-table td:nth-child(3),
.admin-study-table td:nth-child(6) { white-space: normal; }

.patient-id { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }
.uid-cell {
  max-width: 320px;
  word-break: break-all;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

/* Table wraps inside card edges */
.card.table-card { padding: 0; overflow-x: auto; }
.card.table-card .data-table thead th:first-child,
.card.table-card .data-table tbody td:first-child { padding-left: 18px; }
.card.table-card .data-table thead th:last-child,
.card.table-card .data-table tbody td:last-child  { padding-right: 18px; }
/* Custom scrollbar treatment */
.card.table-card::-webkit-scrollbar { height: 10px; }
.card.table-card::-webkit-scrollbar-track { background: var(--surface-2); }
.card.table-card::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--surface-2); }
.card.table-card::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Status pills — outlined, restrained ─────────────────────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  text-transform: capitalize;
}
.status-pill::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.85;
}
.status-active   { color: var(--ok);   background: var(--ok-bg);   border-color: var(--ok-border); }
.status-inactive { color: var(--muted); background: var(--surface-2); border-color: var(--border); }

/* Generic role/modality pill */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid var(--border);
}

/* ── KPI / stat cards (used on home/dashboard) ───────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum", "ss01";
}
.stat-meta { font-size: 12px; color: var(--muted); }

/* ── Filter bar ──────────────────────────────────────────────────────────── */
.filter-form {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 12px;
  align-items: end;
}
.filter-field { display: flex; flex-direction: column; gap: 6px; }
.filter-actions { display: flex; flex-direction: column; gap: 6px; }
.filter-buttons { display: flex; gap: 8px; align-items: center; }

/* ── Grids ───────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-form { display: grid; grid-template-columns: 2fr 1fr auto; gap: 12px; align-items: end; }
.grid-form-button { min-width: 180px; }
.grid-form-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: end; }
.stack-form { display: grid; gap: 8px; min-width: 180px; }

.top-gap { margin-top: 16px; }
.page-actions { margin-top: 20px; display: flex; gap: 8px; }

/* ── Detail grid (used on share_created, share_landing) ──────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 4px;
}
.detail-grid > div { display: flex; flex-direction: column; gap: 4px; }
.detail-grid strong {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.detail-grid > div > div:not(:first-child) {
  font-size: 13.5px;
  color: var(--text);
}

/* ── Share-link box ──────────────────────────────────────────────────────── */
.share-link-block { margin-top: 12px; }
.share-link-block label { margin-bottom: 6px; }
.share-link-box {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.share-link-box input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--surface-2);
}
.copy-status {
  margin-top: 8px;
  color: var(--ok);
  font-weight: 600;
  font-size: 12.5px;
}

/* ── Assign / share inline forms (admin studies) ─────────────────────────── */
.assign-cell { min-width: 260px; }
.assign-inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.assign-inline-form select { width: 168px; min-width: 168px; }
.assign-inline-form .btn   { min-width: 72px; }

.share-cell { min-width: 320px; }
.share-inline-form {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: nowrap;
}
.mini-input-cell { width: 90px; min-width: 90px; }
.mini-input-cell input {
  width: 72px;
  min-width: 72px;
  padding: 7px 8px;
  text-align: center;
  font-family: var(--font-mono);
}
.mini-field { display: flex; flex-direction: column; gap: 4px; }
.mini-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.mini-field input { width: 72px; min-width: 72px; padding: 7px 8px; }

.share-button-cell { width: 140px; min-width: 140px; }
.share-button-cell .btn { min-width: 120px; }
.share-inline-form .btn  { min-width: 120px; }

.password-reset-form { display: flex; gap: 8px; align-items: center; min-width: 220px; }
.password-reset-form input { min-width: 140px; }

/* ── Password visibility toggle ──────────────────────────────────────────── */
.pw-wrap { position: relative; display: flex; align-items: center; }
.pw-wrap input { padding-right: 36px; }
.pw-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--muted);
  display: flex;
  align-items: center;
  border-radius: 4px;
  line-height: 1;
}
.pw-toggle:hover  { color: var(--text); }
.pw-toggle:focus-visible { outline: 2px solid var(--accent); }

/* ── Login / centred-card surfaces ───────────────────────────────────────── */
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.login-logo-wrap { text-align: center; margin-bottom: 16px; }
.login-logo { max-width: 60px; max-height: 60px; object-fit: contain; }
.login-title {
  text-align: center;
  margin: 0 0 4px 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.login-subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0 0 20px 0;
  font-size: 13px;
}
.login-help { margin-top: 18px; text-align: center; font-size: 12.5px; color: var(--muted); }
.center-panel {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ── Empty / error state ─────────────────────────────────────────────────── */
.error-glyph {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 600;
  color: var(--muted);
  line-height: 1;
  letter-spacing: -0.02em;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid-2, .grid-form, .grid-form-2 { grid-template-columns: 1fr; }
  .grid-form-button { min-width: auto; }
}
@media (max-width: 1400px) {
  .admin-study-table { table-layout: fixed; }
  .admin-study-table th,
  .admin-study-table td { white-space: normal; }
  .assign-inline-form,
  .share-inline-form { flex-wrap: wrap; }
}
@media (max-width: 1000px) {
  .filter-form { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-footer { flex-direction: row; align-items: center; justify-content: space-between; }
  .sidebar-actions { flex: 0 0 auto; }
  .page-shell { padding: 16px; }
}
