/* BDS Services portal — base styles shared by the public form and the admin area.
   Tokens mirror client/src/theme/theme.ts (logo raspberry/plum, neutral greys, Inter, 10px radius). */

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('../fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
    U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113,
    U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light;
  --primary: #a41057;
  --primary-dark: #73214e;
  --primary-light: #c6035d;
  --on-primary: #ffffff;
  --secondary: #5d294a;
  --bg: #f7f6f8;
  --paper: #ffffff;
  --text: #18181b;
  --text-2: #52525b;
  --divider: #e4e4e7;
  --line: #d4d4d8;
  --line-hover: #a1a1aa;
  --hover: rgba(24, 24, 27, 0.05);
  --placeholder: #a1a1aa;
  --primary-tint: rgba(164, 16, 87, 0.08);
  --error: #d32f2f;
  --error-bg: #fdeded;
  --error-text: #5f2120;
  --warning: #ed6c02;
  --warning-bg: #fff4e5;
  --warning-text: #663c00;
  --info: #0288d1;
  --info-bg: #e5f6fd;
  --info-text: #014361;
  --success: #2e7d32;
  --success-bg: #edf7ed;
  --success-text: #1e4620;
  --chip-info: #0288d1;
  --chip-success: #2e7d32;
  --chip-warning: #ed6c02;
  --chip-error: #d32f2f;
  --shadow-1: 0 2px 4px rgba(24, 16, 22, 0.06), 0 1px 2px rgba(24, 16, 22, 0.04);
  --shadow-3: 0 6px 14px rgba(24, 16, 22, 0.1), 0 1px 2px rgba(24, 16, 22, 0.04);
  --radius: 10px;
  --logo-chip: transparent;
  --font: 'Inter Variable', 'Inter', 'Segoe UI', Roboto, system-ui, sans-serif;
}

/* Dark follows the OS unless the visitor chose a mode (common.js sets <html data-theme>). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --primary: #f0679e;
    --primary-dark: #d94c86;
    --primary-light: #f58fb8;
    --on-primary: #141116;
    --secondary: #c9a3bc;
    --bg: #141116;
    --paper: #1c181f;
    --text: #f4f4f5;
    --text-2: #a1a1aa;
    --divider: rgba(161, 161, 170, 0.18);
    --line: rgba(161, 161, 170, 0.28);
    --line-hover: #71717a;
    --hover: rgba(244, 244, 245, 0.08);
    --placeholder: #71717a;
    --primary-tint: rgba(240, 103, 158, 0.12);
    --error: #f44336;
    --error-bg: #160a0a;
    --error-text: #f4c7c7;
    --warning-bg: #1a1100;
    --warning-text: #ffe2b7;
    --info-bg: #0a1419;
    --info-text: #b8e7fb;
    --success-bg: #0c130d;
    --success-text: #cce8cd;
    --chip-info: #29b6f6;
    --chip-success: #66bb6a;
    --chip-warning: #ffa726;
    --chip-error: #f44336;
    --shadow-1: 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-3: 0 8px 18px rgba(0, 0, 0, 0.45);
    --logo-chip: #ffffff;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --primary: #f0679e;
  --primary-dark: #d94c86;
  --primary-light: #f58fb8;
  --on-primary: #141116;
  --secondary: #c9a3bc;
  --bg: #141116;
  --paper: #1c181f;
  --text: #f4f4f5;
  --text-2: #a1a1aa;
  --divider: rgba(161, 161, 170, 0.18);
  --line: rgba(161, 161, 170, 0.28);
  --line-hover: #71717a;
  --hover: rgba(244, 244, 245, 0.08);
  --placeholder: #71717a;
  --primary-tint: rgba(240, 103, 158, 0.12);
  --error: #f44336;
  --error-bg: #160a0a;
  --error-text: #f4c7c7;
  --warning-bg: #1a1100;
  --warning-text: #ffe2b7;
  --info-bg: #0a1419;
  --info-text: #b8e7fb;
  --success-bg: #0c130d;
  --success-text: #cce8cd;
  --chip-info: #29b6f6;
  --chip-success: #66bb6a;
  --chip-warning: #ffa726;
  --chip-error: #f44336;
  --shadow-1: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-3: 0 8px 18px rgba(0, 0, 0, 0.45);
  --logo-chip: #ffffff;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  scroll-padding-top: 88px;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5, h6, p { margin: 0; }
h1, h2, h3, h4 { letter-spacing: -0.01em; font-weight: 700; line-height: 1.2; }
h5, h6 { font-weight: 650; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 2000; padding: 8px 16px; border-radius: 8px;
  background: var(--primary); color: var(--on-primary); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 8px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}

/* ── Typography helpers ─────────────────────────────── */
.text-2 { color: var(--text-2); }
.caption { font-size: 0.75rem; line-height: 1.66; color: var(--text-2); }
.body2 { font-size: 0.875rem; line-height: 1.43; }
.fw-600 { font-weight: 600; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.anywhere { overflow-wrap: anywhere; }

/* ── Layout helpers ─────────────────────────────────── */
.container { max-width: 900px; margin: 0 auto; padding: 0 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }

/* ── Surfaces ───────────────────────────────────────── */
.paper { background: var(--paper); border-radius: var(--radius); }
.paper-outlined { background: var(--paper); border: 1px solid var(--divider); border-radius: var(--radius); }
.card { background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.pad { padding: 16px; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 0 20px; border: 1px solid transparent; border-radius: 10px; background: transparent;
  color: var(--primary); font-weight: 600; font-size: 0.9375rem; line-height: 1; cursor: pointer;
  text-decoration: none; transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--primary-tint); }
.btn:disabled, .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-contained { background: var(--primary); color: var(--on-primary); }
.btn-contained:hover { background: var(--primary-dark); }
:root[data-theme='dark'] .btn-contained:hover { background: var(--primary-light); }
.btn-outlined { border-color: color-mix(in srgb, var(--primary) 50%, transparent); }
.btn-outlined:hover { border-color: var(--primary); }
.btn-inherit { color: var(--text-2); }
.btn-inherit:hover { background: var(--hover); }
.btn-inherit.btn-outlined { border-color: var(--line); color: var(--text); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { background: #b71c1c; }
.btn-lg { min-height: 48px; font-size: 1rem; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.8125rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--hover); }
.icon { width: 1.25em; height: 1.25em; fill: currentColor; flex: none; display: inline-block; vertical-align: middle; }

/* ── Form fields (outlined, as MUI) ─────────────────── */
.field { display: flex; flex-direction: column; min-width: 0; }
.field > label, .field-label {
  font-size: 0.875rem; font-weight: 500; color: var(--text-2); margin-bottom: 6px;
}
.field .req { color: var(--error); }
.input, .select, .textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; background: var(--paper); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius); font-size: 1rem; line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s; appearance: none; -webkit-appearance: none;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--line-hover); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary);
}
.input::placeholder, .textarea::placeholder { color: var(--placeholder); opacity: 1; }
.textarea { resize: vertical; min-height: 96px; }
.select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='%23888'><path d='M7 10l5 5 5-5z'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 20px;
}
.input[type='date'], .input[type='time'] { appearance: auto; -webkit-appearance: auto; }
.input[aria-invalid='true'], .select[aria-invalid='true'], .textarea[aria-invalid='true'] {
  border-color: var(--error);
}
.input[aria-invalid='true']:focus, .select[aria-invalid='true']:focus { box-shadow: 0 0 0 1px var(--error); }
.input:disabled, .select:disabled { opacity: 0.6; cursor: not-allowed; }
.input-group { position: relative; display: flex; align-items: stretch; }
.input-group .affix {
  display: flex; align-items: center; padding: 0 12px; color: var(--text-2); background: var(--hover);
  border: 1px solid var(--line); font-size: 1rem;
}
.input-group .affix.pre { border-right: 0; border-radius: var(--radius) 0 0 var(--radius); }
.input-group .affix.post { border-left: 0; border-radius: 0 var(--radius) var(--radius) 0; }
.input-group .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.help { font-size: 0.75rem; line-height: 1.66; color: var(--text-2); margin: 4px 2px 0; }
.error-text { font-size: 0.75rem; line-height: 1.66; color: var(--error); margin: 4px 2px 0; }
.field.has-error > label, .field.has-error > .field-label { color: var(--error); }

.choice-row { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.choice {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; font-size: 1rem;
}
.choice input { width: 20px; height: 20px; accent-color: var(--primary); margin: 0; cursor: pointer; }
fieldset.field { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset.field > legend { padding: 0; font-size: 0.875rem; font-weight: 500; color: var(--text-2); margin-bottom: 4px; }

.form-grid { display: grid; gap: 20px 16px; grid-template-columns: minmax(0, 1fr); }
.form-grid .full { grid-column: 1 / -1; }
@media (min-width: 600px) { .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ── Alerts ─────────────────────────────────────────── */
.alert {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; border-radius: 10px;
  font-size: 0.875rem; line-height: 1.5;
}
.alert .alert-body { flex: 1; min-width: 0; }
.alert .alert-actions { display: flex; align-items: center; gap: 4px; flex: none; }
.alert-error { background: var(--error-bg); color: var(--error-text); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); }
.alert-info { background: var(--info-bg); color: var(--info-text); }
.alert-success { background: var(--success-bg); color: var(--success-text); }
.alert-error > .icon:first-child { color: var(--error); }
.alert-warning > .icon:first-child { color: var(--warning); }
.alert-info > .icon:first-child { color: var(--info); }
.alert-success > .icon:first-child { color: var(--success); }
.alert .btn { color: inherit; min-height: 32px; padding: 0 10px; font-size: 0.8125rem; }
.alert .icon-btn { min-width: 32px; min-height: 32px; color: inherit; }

/* ── Chips ──────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: 16px;
  font-size: 0.8125rem; font-weight: 600; border: 1px solid var(--line); color: var(--text); white-space: nowrap;
}
.chip-lg { height: 32px; padding: 0 12px; }
.chip.status { min-width: 92px; justify-content: center; border-color: transparent; color: #fff; }
.chip.status-pending { background: transparent; border-color: var(--line); color: var(--text); }
.chip.status-shortlisted { background: var(--chip-info); }
.chip.status-on_hold { background: var(--chip-warning); }
.chip.status-selected { background: var(--chip-success); }
.chip.status-rejected { background: var(--chip-error); }
:root[data-theme='dark'] .chip.status:not(.status-pending) { color: #141116; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .chip.status:not(.status-pending) { color: #141116; } }
.chip-stage { color: var(--text-2); font-weight: 500; }
.chip-outlined-primary { color: var(--primary); border-color: var(--primary); background: transparent; }
.chip-active { background: var(--success-bg); color: var(--success-text); border-color: transparent; }
.chip-inactive { background: var(--hover); color: var(--text-2); border-color: transparent; }
.chip-locked { background: var(--warning-bg); color: var(--warning-text); border-color: transparent; }

/* ── Dialog ─────────────────────────────────────────── */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 1300; background: rgba(0, 0, 0, 0.5); display: flex;
  align-items: center; justify-content: center; padding: 16px; overflow-y: auto;
}
.dialog {
  background: var(--paper); border-radius: 14px; box-shadow: var(--shadow-3); width: 100%; max-width: 480px;
  max-height: calc(100dvh - 32px); display: flex; flex-direction: column; margin: auto;
}
.dialog-lg { max-width: 640px; }
.dialog-xl { max-width: 960px; height: calc(100dvh - 32px); }
.dialog > h2 { font-size: 1.25rem; padding: 20px 24px 8px; }
.dialog-content { padding: 8px 24px 16px; overflow-y: auto; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding: 12px 24px 20px; }
@media (max-width: 599px) {
  .dialog > h2 { padding: 16px 16px 8px; }
  .dialog-content { padding: 8px 16px 16px; }
  .dialog-actions { padding: 8px 16px 16px; }
  .dialog-actions .btn { flex: 1; }
}

/* ── Toast ──────────────────────────────────────────── */
.toast-host {
  position: fixed; left: 0; right: 0; bottom: 16px; z-index: 1500; display: flex; flex-direction: column;
  align-items: center; gap: 8px; padding: 0 16px; pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; min-width: min(344px, 100%);
  max-width: 560px; padding: 8px 8px 8px 16px; border-radius: 8px; color: #fff; font-size: 0.875rem;
  box-shadow: var(--shadow-3);
}
.toast-success { background: #2e7d32; } .toast-error { background: #d32f2f; }
.toast-info { background: #0277bd; } .toast-warning { background: #e65100; }
.toast .icon-btn { color: #fff; min-width: 32px; min-height: 32px; }

/* ── Tabs / progress / skeleton ─────────────────────── */
.tabs { display: flex; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -ms-overflow-style: none; border-bottom: 1px solid var(--divider); }
.tabs::-webkit-scrollbar { display: none; } /* no scrollbars on the tab bar; it still scrolls sideways by touch / arrow keys on small screens */
.tab {
  flex: none; min-height: 48px; padding: 0 16px; border: 0; background: transparent; color: var(--text-2);
  font-weight: 600; font-size: 0.875rem; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { background: var(--hover); }
.tab[aria-selected='true'] { color: var(--primary); border-bottom-color: var(--primary); }
@media (max-width: 899px) {
  .tabs { flex-wrap: wrap; overflow: visible; }
  .tab { flex: 1 1 auto; min-height: 44px; padding: 0 12px; margin-bottom: 0; border-bottom-width: 3px; }
  .tab[aria-selected='true'] { background: var(--primary-tint); }
}
.progress { height: 6px; border-radius: 3px; background: var(--primary-tint); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.25s; }
.skeleton { display: block; border-radius: 6px; background: var(--hover); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ── Empty / status pages ───────────────────────────── */
.empty { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty.compact { padding: 32px 16px; }
.empty .empty-icon { font-size: 48px; opacity: 0.6; }
.empty h3 { color: var(--text); font-size: 1.125rem; margin: 8px 0 4px; }
.empty .btn { margin-top: 16px; }
.status-page {
  min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 12px;
}
.status-page .code { font-size: 4rem; font-weight: 700; color: var(--primary); line-height: 1; }

/* ── Tables (admin) ─────────────────────────────────── */
.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data th {
  text-align: left; font-weight: 600; color: var(--text-2);
  background: color-mix(in srgb, var(--text) 3%, var(--paper));
  padding: 0 16px; height: 56px; white-space: nowrap; border-bottom: 1px solid var(--divider);
}
table.data td { padding: 0 16px; height: 52px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--hover); }
table.data .num { text-align: right; }
/* Cards below 1100px: seven columns don't fit next to the 260px menu before that. Two columns of fields on tablets. */
@media (max-width: 1099px) {
  table.data.cards, table.data.cards tbody { display: block; }
  table.data.cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  table.data.cards tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--divider); }
  table.data.cards tr:last-child { border-bottom: 0; }
  table.data.cards td { display: block; height: auto; padding: 4px 0; border: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
  table.data.cards td::before { content: attr(data-label); display: block; color: var(--text-2); font-size: 0.75rem; font-weight: 600; }
  table.data.cards td:first-child { font-size: 1rem; padding-top: 0; }
  table.data.cards td:first-child::before { display: none; }
  table.data.cards tbody tr:hover { background: transparent; }
}
@media (min-width: 600px) and (max-width: 1099px) {
  table.data.cards tr { display: grid; grid-template-columns: 1fr 1fr; column-gap: 24px; }
  table.data.cards td:first-child, table.data.cards td:last-child { grid-column: 1 / -1; }
}
table.data th.sortable button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
table.data th.sortable button:focus-visible { outline: 2px solid var(--primary); }
.sort-ind { opacity: 0.35; font-size: 0.75rem; }
th[aria-sort] .sort-ind { opacity: 1; color: var(--primary); }
.pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 16px;
  padding: 8px 12px; font-size: 0.875rem; color: var(--text-2); border-top: 1px solid var(--divider);
}
@media (max-width: 599px) {
  .pager { gap: 4px 8px; padding: 8px; justify-content: space-between; }
  .form-actions .btn { flex: 1; } /* primary form button spans the phone width */
}
table.data.cards td.anywhere { min-width: 190px; } /* e-mail addresses wrap at '@' / '.', not letter by letter */
.pager .select { width: auto; min-height: 36px; padding: 4px 28px 4px 8px; font-size: 0.875rem; }
.pager .icon-btn[disabled] { opacity: 0.35; pointer-events: none; }
