:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-alt: #f0f4f1;
  --ink: #1c2320;
  --muted: #626d68;
  --line: #dce3df;
  --line-strong: #c5d0ca;
  --teal: #147d74;
  --teal-soft: #dff2ef;
  --amber: #a96d00;
  --amber-soft: #fff0cc;
  --rose: #b64f65;
  --rose-soft: #fde5eb;
  --indigo: #4d5db8;
  --indigo-soft: #e8ebff;
  --success: #1f7a4d;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(26, 39, 35, .10);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(20, 125, 116, .24);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(223, 242, 239, .55), rgba(246, 247, 244, 0) 320px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .58;
}

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

a:hover {
  text-decoration: underline;
}

svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.skip-link,
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  top: 12px;
  left: 12px;
  z-index: 30;
  width: auto;
  height: auto;
  padding: 10px 12px;
  clip: auto;
  color: var(--surface);
  background: var(--teal);
  border-radius: var(--radius);
}

.is-hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 430px);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand-row,
.sidebar-brand,
.candidate-card,
.topbar-actions,
.login-meta,
.status-cluster {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 14px;
  margin-bottom: 28px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  color: var(--surface);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .28), rgba(255, 255, 255, 0)),
    var(--teal);
  border-radius: var(--radius);
  font-weight: 800;
}

.brand-mark.small {
  width: 40px;
  height: 40px;
  font-size: 13px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.2;
}

h3 {
  margin-bottom: 0;
  font-size: 24px;
  line-height: 1.2;
}

h4 {
  margin-bottom: 0;
  font-size: 16px;
}

.stack {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  outline: none;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  box-shadow: var(--focus);
  outline: none;
}

.password-wrap,
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  padding-right: 50px;
}

.password-wrap .icon-button {
  position: absolute;
  right: 4px;
}

.field-error {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

.field-help,
.form-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.form-note {
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.login-meta {
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: 16px;
  min-height: 16px;
}

.primary-action,
.small-button,
.text-button,
.icon-button,
.nav-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  transition: background .16s ease, color .16s ease, border-color .16s ease, transform .16s ease;
}

.primary-action {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--surface);
  background: var(--teal);
  border: 1px solid var(--teal);
  font-weight: 800;
}

.primary-action:hover {
  background: #0f6961;
}

.primary-action.compact {
  width: auto;
  min-height: 40px;
}

.small-button {
  min-height: 38px;
  padding: 9px 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  font-weight: 700;
}

.small-button:hover,
.icon-button:hover,
.text-button:hover,
.nav-item:hover {
  background: var(--surface-alt);
}

.small-button.full {
  width: 100%;
}

.text-button {
  min-height: 36px;
  padding: 8px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  font-weight: 700;
}

.icon-button {
  position: relative;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
}

.icon-button.ghost {
  background: transparent;
  border-color: transparent;
}

.fallback-icon {
  display: none;
  font-size: 11px;
}

.security-strip {
  display: flex;
  gap: 8px;
  margin-top: 18px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--surface-alt);
  border-radius: var(--radius);
  font-size: 13px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 18px;
  background: #fbfcfa;
  border-right: 1px solid var(--line);
}

.sidebar-brand {
  gap: 10px;
}

.sidebar-brand strong,
.sidebar-brand span {
  display: block;
}

.sidebar-brand span {
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  justify-content: flex-start;
  padding: 10px 12px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  font-weight: 750;
}

.nav-item.is-active {
  color: var(--teal);
  background: var(--teal-soft);
  border-color: #b7dfd9;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.role-chip,
.status-pill {
  display: inline-flex;
  width: fit-content;
  min-height: 28px;
  align-items: center;
  padding: 5px 10px;
  color: var(--muted);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.success {
  color: var(--success);
  background: #e5f5ec;
  border-color: #bde5ce;
}

.status-pill.warning {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #f4cf7e;
}

.status-pill.danger {
  color: var(--danger);
  background: #fee7e2;
  border-color: #ffcdc3;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 76px;
  padding: 14px 24px;
  background: rgba(246, 247, 244, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.menu-button {
  display: none;
}

.topbar-actions {
  margin-left: auto;
  gap: 10px;
}

.search-box {
  min-width: min(360px, 34vw);
}

.search-box svg {
  position: absolute;
  left: 11px;
  color: var(--muted);
}

.search-box input {
  padding-left: 38px;
}

.badge-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background: var(--rose);
  border: 2px solid var(--surface);
  border-radius: 50%;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--surface);
  background: var(--indigo);
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
}

.main-content {
  padding: 24px;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.view-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.metric-grid,
.dashboard-grid,
.security-grid,
.support-grid,
.validation-layout {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric-card,
.panel,
.table-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.metric-card {
  min-height: 152px;
  padding: 18px;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card span,
.metric-card strong,
.metric-card small {
  display: block;
}

.metric-card strong {
  margin: 10px 0 2px;
  font-size: 30px;
  line-height: 1;
}

.metric-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: var(--radius);
}

.metric-icon.teal {
  color: var(--teal);
  background: var(--teal-soft);
}

.metric-icon.amber {
  color: var(--amber);
  background: var(--amber-soft);
}

.metric-icon.rose {
  color: var(--rose);
  background: var(--rose-soft);
}

.metric-icon.indigo {
  color: var(--indigo);
  background: var(--indigo-soft);
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
}

.panel {
  padding: 18px;
}

.queue-list,
.item-list,
.quality-bars,
.checklist {
  display: grid;
  gap: 12px;
}

.queue-row,
.validation-item,
.support-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.queue-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.queue-row strong,
.queue-row span,
.support-card strong,
.support-card span {
  display: block;
}

.queue-row span,
.support-card span,
.candidate-card p,
.data-list dd,
.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.quality-bars div {
  display: grid;
  gap: 6px;
}

progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-alt);
}

progress::-webkit-progress-bar {
  background: var(--surface-alt);
}

progress::-webkit-progress-value {
  background: var(--teal);
}

progress::-moz-progress-bar {
  background: var(--teal);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.segmented button {
  min-height: 32px;
  padding: 6px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 750;
}

.segmented .is-selected {
  color: var(--teal);
  background: var(--teal-soft);
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 160px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.compact-field {
  gap: 5px;
}

.compact-field input,
.compact-field select {
  min-height: 38px;
}

.table-shell {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #fbfcfa;
  font-size: 12px;
  text-transform: uppercase;
}

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

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.validation-layout {
  grid-template-columns: 300px minmax(0, 1fr);
  align-items: start;
}

.candidate-card {
  gap: 12px;
  margin-bottom: 18px;
}

.candidate-photo {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  color: var(--surface);
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .32), transparent 30%),
    var(--rose);
  border-radius: var(--radius);
  font-weight: 900;
}

.data-list {
  display: grid;
  gap: 10px;
  margin: 0 0 18px;
}

.data-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.data-list dt {
  color: var(--muted);
  font-size: 13px;
}

.data-list dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
}

.validation-item {
  grid-template-columns: minmax(0, 1fr) 150px minmax(180px, .7fr) auto;
  align-items: center;
}

.validation-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.legacy-section {
  display: block;
}

.legacy-section .panel-head {
  margin-bottom: 16px;
}

.legacy-form-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.compact-legacy-grid {
  margin-top: 18px;
}

.col-1 {
  grid-column: span 1;
}

.col-2 {
  grid-column: span 2;
}

.col-3 {
  grid-column: span 3;
}

.col-4 {
  grid-column: span 4;
}

.col-5 {
  grid-column: span 5;
}

.col-6 {
  grid-column: span 6;
}

.col-12 {
  grid-column: span 12;
}

.grade-options {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 8px 0;
}

.grade-options label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

.grade-options input {
  accent-color: var(--teal);
}

.resume-section {
  margin-top: 16px;
}

.compact-table {
  margin-top: 16px;
}

.compact-table table {
  min-width: 720px;
}

.inline-support {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(220px, 320px);
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.inline-support strong,
.inline-support small,
.support-kicker {
  display: block;
}

.inline-support small {
  margin-top: 4px;
  color: var(--muted);
}

.support-kicker {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.compact-upload {
  min-height: 54px;
  padding: 10px 12px;
}

.span-2 {
  grid-column: span 2;
}

.form-actions,
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.support-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.support-card {
  min-height: 170px;
}

.support-card table {
  min-width: 0;
  font-size: 14px;
}

.support-card th,
.support-card td {
  padding: 10px 4px;
}

.support-card .upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.support-card .upload-zone {
  min-height: 42px;
  padding: 8px 10px;
}

.support-file-name {
  color: var(--ink);
}

.support-file-meta {
  color: var(--muted);
  white-space: nowrap;
}

.support-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.upload-zone {
  display: grid;
  place-items: center;
  min-height: 74px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  text-align: center;
  font-size: 13px;
}

.security-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr);
}

.code-block {
  overflow-x: auto;
  margin: 0;
  padding: 14px;
  color: #10211e;
  background: #eef4f1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  line-height: 1.55;
  white-space: pre-wrap;
}

.checklist {
  padding: 0;
  margin: 0;
  list-style: none;
}

.checklist li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  background: #fbfcfa;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(22, 31, 28, .42);
}

.modal {
  width: min(100%, 560px);
  max-height: min(760px, 90vh);
  overflow-y: auto;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-form {
  display: grid;
  gap: 14px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  color: var(--surface);
  background: var(--ink);
  border-radius: var(--radius);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1100px) {
  .metric-grid,
  .support-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .security-grid,
  .validation-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 25;
    width: min(84vw, 300px);
    transform: translateX(-100%);
    transition: transform .18s ease;
    box-shadow: var(--shadow);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .menu-button {
    display: inline-flex;
  }

  .topbar {
    align-items: flex-start;
    padding: 12px 16px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .search-box {
    display: none;
  }

  .main-content {
    padding: 16px;
  }

  .view-head,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-bar,
  .form-grid,
  .legacy-form-grid,
  .validation-item {
    grid-template-columns: 1fr;
  }

  .col-1,
  .col-2,
  .col-3,
  .col-4,
  .col-5,
  .col-6,
  .col-12 {
    grid-column: auto;
  }

  .inline-support {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .span-2 {
    grid-column: auto;
  }

  .form-actions {
    justify-content: stretch;
    flex-direction: column;
  }

  .form-actions .small-button,
  .form-actions .primary-action {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .login-screen {
    padding: 12px;
    align-items: start;
  }

  .login-card {
    padding: 20px;
    margin-top: 28px;
  }

  .metric-grid,
  .support-grid {
    grid-template-columns: 1fr;
  }

  .login-meta {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }
}
