/* myNUCuLIS Admin — "Clinical Trust" palette (deep navy brand + mid teal
   accent), extended with a wider accent range for stat chips / status
   badges so the dashboard reads as a modern, colorful product rather than
   a flat back-office form. */

:root {
  --radius: 0.875rem;
  --radius-sm: calc(var(--radius) - 4px);
  --radius-lg: var(--radius);
  --radius-xl: calc(var(--radius) + 6px);

  --brand: #072a52;
  --brand-light: #0e4784;
  --brand-foreground: #ffffff;

  --background: oklch(0.97 0.006 240);
  --foreground: oklch(0.2 0.04 250);

  --card: oklch(1 0 0);
  --card-foreground: oklch(0.2 0.04 250);

  --primary: oklch(0.34 0.1 255);
  --primary-foreground: oklch(0.98 0.01 220);

  --secondary: oklch(0.95 0.015 240);
  --secondary-foreground: oklch(0.25 0.05 250);

  --muted: oklch(0.96 0.01 235);
  --muted-foreground: oklch(0.5 0.03 250);

  --accent: oklch(0.68 0.14 195);
  --accent-foreground: oklch(0.99 0 0);

  --mint: oklch(0.8 0.1 190);
  --destructive: oklch(0.58 0.21 25);
  --destructive-foreground: oklch(0.99 0 0);

  --violet: oklch(0.55 0.19 290);
  --amber: oklch(0.72 0.15 70);
  --rose: oklch(0.62 0.19 15);
  --emerald: oklch(0.62 0.14 155);
  --sky: oklch(0.62 0.13 235);

  --border: oklch(0.91 0.012 230);
  --input: oklch(0.92 0.012 230);
  --ring: oklch(0.62 0.13 200);

  --shadow-soft: 0 1px 2px rgba(7, 42, 82, 0.04), 0 8px 24px -12px rgba(7, 42, 82, 0.14);
  --shadow-elevated: 0 24px 60px -20px rgba(7, 42, 82, 0.35);
  --shadow-hover: 0 4px 16px -4px rgba(7, 42, 82, 0.18);

  --skeleton-base: oklch(0.94 0.01 235);
  --skeleton-shine: oklch(0.99 0.005 235);

  --sidebar-width: 16rem;
  --sidebar-width-collapsed: 4.5rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0 0 0.5rem;
  color: oklch(0.18 0.04 255);
}

h1 {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

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

p {
  margin: 0 0 0.75rem;
  color: var(--muted-foreground);
}

.icon {
  flex-shrink: 0;
  vertical-align: -3px;
}

.mono {
  font-variant-numeric: tabular-nums;
  font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85em;
  color: var(--primary);
  font-weight: 600;
}

/* ---------------------------------------------------------------- shell */

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

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--brand) 0%, #051b3e 100%);
  color: var(--brand-foreground);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  transition: transform 0.2s ease;
  box-shadow: 4px 0 24px -8px rgba(0, 0, 0, 0.25);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1.35rem 1.25rem;
  border-bottom: 1px solid color-mix(in oklab, white 12%, transparent);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-collapse-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  background: color-mix(in oklab, white 10%, transparent);
  border: none;
  border-radius: var(--radius-sm);
  color: color-mix(in oklab, white 85%, transparent);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.2s ease;
}
.sidebar-collapse-toggle:hover {
  background: color-mix(in oklab, white 18%, transparent);
  color: white;
}

.sidebar-brand em {
  font-style: normal;
  font-weight: 400;
  opacity: 0.75;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  border-radius: 0.55rem;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: white;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 4px 12px -4px rgba(0, 0, 0, 0.4);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.65rem;
}

.sidebar-foot {
  padding: 0.65rem;
  border-top: 1px solid color-mix(in oklab, white 12%, transparent);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  color: color-mix(in oklab, white 82%, transparent);
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-link .icon {
  opacity: 0.85;
}

.sidebar-link:hover {
  background: color-mix(in oklab, white 8%, transparent);
  color: white;
  text-decoration: none;
}

.sidebar-link.active {
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  color: white;
  font-weight: 600;
}
.sidebar-link.active .icon {
  opacity: 1;
  color: oklch(0.85 0.12 195);
}
.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: -0.65rem;
  top: 0.35rem;
  bottom: 0.35rem;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  transition: margin-left 0.2s ease;
}

/* ------------------------------------------------------ collapsed sidebar */

html.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

html.sidebar-collapsed .main {
  margin-left: var(--sidebar-width-collapsed);
}

html.sidebar-collapsed .sidebar-brand {
  padding-left: 0.9rem;
  padding-right: 0.9rem;
}

html.sidebar-collapsed .brand-text,
html.sidebar-collapsed .sidebar-link-text {
  display: none;
}

html.sidebar-collapsed .sidebar-collapse-toggle {
  transform: rotate(180deg);
}

html.sidebar-collapsed .sidebar-link {
  justify-content: center;
}

html.sidebar-collapsed .sidebar-link.active::before {
  left: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.75rem;
  background: color-mix(in oklab, var(--card) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: oklch(0.18 0.04 255);
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--foreground);
  padding: 0.3rem;
  border-radius: var(--radius-sm);
}
.menu-toggle:hover {
  background: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.account-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--foreground);
  background: color-mix(in oklab, var(--accent) 12%, white);
  border: 1px solid color-mix(in oklab, var(--accent) 25%, transparent);
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.account-badge:hover {
  text-decoration: none;
  background: color-mix(in oklab, var(--accent) 20%, white);
  border-color: color-mix(in oklab, var(--accent) 40%, transparent);
}
.account-badge-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.account-badge-text strong {
  font-size: 0.8rem;
  color: oklch(0.22 0.05 250);
}
.account-badge-text small {
  font-size: 0.68rem;
  color: var(--muted-foreground);
}
.account-badge-swap {
  color: var(--accent);
  opacity: 0.85;
}

.admin-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--foreground);
  background: var(--muted);
  padding: 0.35rem 0.7rem 0.35rem 0.4rem;
  border-radius: 999px;
}

.admin-avatar {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
}

.content {
  padding: 1.75rem;
  max-width: 1400px;
  width: 100%;
}

/* ---------------------------------------------------------------- flash */

.flash {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
  box-shadow: var(--shadow-soft);
  animation: admin-fade-in 0.2s ease;
}

.flash-success {
  background: color-mix(in oklab, var(--emerald) 14%, white);
  border-color: color-mix(in oklab, var(--emerald) 35%, transparent);
  color: oklch(0.35 0.1 155);
}

.flash-error {
  background: color-mix(in oklab, var(--destructive) 10%, white);
  border-color: color-mix(in oklab, var(--destructive) 35%, transparent);
  color: var(--destructive);
}

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: box-shadow 0.15s ease;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-header h1 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.page-header h1 .icon {
  color: var(--accent);
}
.page-header p {
  margin: 0.15rem 0 0;
}

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

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--muted-foreground);
  padding: 0.65rem 0.9rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.1s ease;
}
tbody tr:hover {
  background: color-mix(in oklab, var(--accent) 5%, transparent);
}
tbody tr:last-child td {
  border-bottom: none;
}

.select-col {
  width: 2.5rem;
  padding-right: 0 !important;
}
.select-col input[type="checkbox"],
.req-row-check,
#req-select-all {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
}

.skeleton-check {
  width: 1.05rem !important;
  height: 1.05rem;
  border-radius: 0.3rem;
}

.selection-bar {
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  border-radius: var(--radius-sm);
  background: color-mix(in oklab, var(--primary) 8%, white);
  border: 1px solid color-mix(in oklab, var(--primary) 22%, transparent);
  font-size: 0.85rem;
  color: var(--foreground);
  animation: admin-fade-in 0.15s ease;
}
/* Same [hidden]-vs-author-CSS specificity tie as .modal-overlay above. */
.selection-bar:not([hidden]) {
  display: flex;
}
.selection-bar strong {
  color: var(--primary);
}
.selection-bar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ------------------------------------------------------------------ toast */

.toast-container {
  position: fixed;
  top: 1.1rem;
  right: 1.1rem;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(24rem, calc(100vw - 2.2rem));
}
.toast-container .flash {
  margin-bottom: 0;
  box-shadow: var(--shadow-elevated);
}

/* ------------------------------------------------------------------ modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: color-mix(in oklab, black 45%, transparent);
  animation: admin-fade-in 0.15s ease;
}
/* [hidden] is a plain attribute selector, so it has the same specificity as
   .modal-overlay — without scoping `display` to :not([hidden]), author CSS
   always wins over the UA stylesheet's default [hidden] { display: none }
   regardless of source order, so the overlay would stay visible even while
   JS has set the hidden attribute. */
.modal-overlay:not([hidden]) {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 34rem;
  max-height: min(38rem, 90vh);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-elevated);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.1rem 1.25rem 0.5rem;
}
.modal-header h3 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.05rem;
}
.modal-header h3 .icon {
  color: var(--accent);
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}
.modal-close:hover {
  background: var(--muted);
  color: var(--foreground);
}

.modal-subtitle {
  padding: 0 1.25rem;
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
}

.modal-tabs {
  gap: 0.3rem;
  padding: 0 1.25rem;
  margin-bottom: 0.75rem;
  overflow-x: auto;
  flex-shrink: 0;
}
/* Same [hidden]-vs-author-CSS specificity tie as .modal-overlay above. */
.modal-tabs:not([hidden]) {
  display: flex;
}

.modal-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.modal-tab:hover {
  background: var(--secondary);
}
.modal-tab.active {
  background: var(--primary);
  color: var(--primary-foreground);
}
.modal-tab .tab-count {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: color-mix(in oklab, white 25%, transparent);
}
.modal-tab:not(.active) .tab-count {
  background: color-mix(in oklab, var(--primary) 18%, transparent);
  color: var(--primary);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.25rem;
}

.modal-loading {
  flex-direction: column;
  gap: 1.1rem;
  padding: 0.25rem 0 0.75rem;
}
/* Same [hidden]-vs-author-CSS specificity tie as .modal-overlay above. */
.modal-loading:not([hidden]) {
  display: flex;
}
.target-group-skeleton {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.target-group-skeleton .skeleton-cell {
  height: 1rem;
}

.target-group {
  padding-bottom: 1rem;
  margin-bottom: 0.85rem;
  border-bottom: 1px solid var(--border);
}
.target-group:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.target-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.target-group-header h4 {
  margin: 0;
  padding: 0;
  border: none;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted-foreground);
}
.target-group-select-all {
  background: none;
  border: none;
  padding: 0;
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.target-group-select-all:hover {
  text-decoration: underline;
}

.target-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.15rem 0.5rem;
}

.target-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.3rem;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.1s ease;
}
.target-option:hover {
  background: var(--muted);
}
.target-option input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}
.target-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.target-option.is-checked {
  color: var(--primary);
  font-weight: 600;
}

.modal-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 0.88rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--muted);
}
.modal-selection-hint {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}
.modal-footer-actions {
  display: flex;
  gap: 0.5rem;
}

.cell-primary {
  font-weight: 600;
  color: oklch(0.22 0.05 250);
}
.cell-secondary {
  font-size: 0.78rem;
  color: var(--muted-foreground);
  margin-top: 0.1rem;
}

.pdf-status-badge {
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.25rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  width: fit-content;
}
/* Same [hidden]-vs-author-CSS specificity tie as .modal-overlay above. */
.pdf-status-badge:not([hidden]) {
  display: inline-flex;
}
.pdf-status-saved {
  background: color-mix(in oklab, var(--emerald) 18%, white);
  color: oklch(0.36 0.12 155);
}
.pdf-status-skipped {
  background: color-mix(in oklab, var(--muted-foreground) 14%, white);
  color: var(--muted-foreground);
}
.pdf-status-failed {
  background: color-mix(in oklab, var(--destructive) 14%, white);
  color: var(--destructive);
}
.pdf-status-pending {
  background: var(--muted);
  color: var(--muted-foreground);
}
.pdf-status-updating {
  background: color-mix(in oklab, var(--accent) 18%, white);
  color: oklch(0.4 0.11 205);
  animation: admin-pdf-status-pulse 1.1s ease-in-out infinite;
}

@keyframes admin-pdf-status-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.55;
  }
}

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.24rem 0.65rem 0.24rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--muted);
  color: var(--muted-foreground);
}
.badge::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.badge-status-submitted {
  background: color-mix(in oklab, var(--sky) 18%, white);
  color: oklch(0.38 0.12 235);
}
.badge-status-in-progress,
.badge-status-in-process,
.badge-status-pending {
  background: color-mix(in oklab, var(--amber) 20%, white);
  color: oklch(0.42 0.12 70);
}
.badge-status-completed {
  background: color-mix(in oklab, var(--emerald) 18%, white);
  color: oklch(0.36 0.12 155);
}
.badge-status-rejected,
.badge-status-cancelled,
.badge-status-canceled {
  background: color-mix(in oklab, var(--destructive) 14%, white);
  color: var(--destructive);
}
.badge-status-unknown {
  background: color-mix(in oklab, var(--muted-foreground) 14%, white);
  color: var(--muted-foreground);
}
.badge-active {
  background: color-mix(in oklab, var(--emerald) 18%, white);
  color: oklch(0.36 0.12 155);
}
.badge-not-sent {
  background: color-mix(in oklab, var(--amber) 18%, white);
  color: oklch(0.42 0.12 70);
}

/* ---------------------------------------------------------------- forms */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.hint {
  font-size: 0.76rem;
  color: var(--muted-foreground);
}

.bulk-create-progress {
  margin-top: 0.5rem;
}
.bulk-create-progress-bar {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--muted);
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.bulk-create-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.2s ease;
}
#bulk-create-progress-label {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--foreground);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--foreground);
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: color-mix(in oklab, var(--ring) 50%, var(--input));
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 22%, transparent);
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.inline-form {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
}

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.05rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:hover {
  text-decoration: none;
}
.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--brand-light));
  color: var(--primary-foreground);
  box-shadow: 0 2px 10px -2px color-mix(in oklab, var(--primary) 55%, transparent);
}
.btn-primary:hover {
  box-shadow: 0 4px 16px -2px color-mix(in oklab, var(--primary) 65%, transparent);
  color: var(--primary-foreground);
}

.btn-secondary {
  background: var(--card);
  color: var(--secondary-foreground);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--muted);
  border-color: color-mix(in oklab, var(--ring) 40%, var(--border));
}

.btn-sm {
  padding: 0.36rem 0.75rem;
  font-size: 0.78rem;
}

.btn-icon {
  padding: 0.4rem;
  width: 2.05rem;
  height: 2.05rem;
}

.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.spinner {
  display: none;
  width: 0.9em;
  height: 0.9em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: admin-spin 0.6s linear infinite;
}
.spinner:not([hidden]) {
  display: inline-block;
}

@keyframes admin-spin {
  to {
    transform: rotate(360deg);
  }
}

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

/* ---------------------------------------------------------------- filters */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.filter-bar select,
.filter-bar input {
  width: auto;
}

.search-box {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.search-box .icon {
  position: absolute;
  left: 0.65rem;
  color: var(--muted-foreground);
  pointer-events: none;
}
.search-box input {
  padding-left: 2.15rem;
  width: 100%;
}

.multi-filter {
  position: relative;
}

.multi-filter-trigger {
  gap: 0.4rem;
}
.multi-filter-trigger.has-value {
  background: color-mix(in oklab, var(--primary) 10%, white);
  border-color: color-mix(in oklab, var(--primary) 35%, transparent);
  color: var(--primary);
}
.multi-filter-trigger.mode-exclude.has-value {
  background: color-mix(in oklab, var(--destructive) 10%, white);
  border-color: color-mix(in oklab, var(--destructive) 35%, transparent);
  color: var(--destructive);
}
.multi-filter-caret {
  transition: transform 0.15s ease;
}
.multi-filter-trigger[aria-expanded="true"] .multi-filter-caret {
  transform: rotate(90deg);
}

.multi-filter-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  z-index: 30;
  width: 15.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated);
  padding: 0.65rem;
  animation: admin-fade-in 0.12s ease;
}

.multi-filter-mode {
  display: flex;
  gap: 0.3rem;
  padding: 0.2rem;
  margin-bottom: 0.55rem;
  background: var(--muted);
  border-radius: var(--radius-sm);
}
.mode-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  padding: 0.35rem 0.5rem;
  border: none;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-btn:hover {
  color: var(--foreground);
}
.mode-btn.active[data-mode="include"] {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow-soft);
}
.mode-btn.active[data-mode="exclude"] {
  background: var(--card);
  color: var(--destructive);
  box-shadow: var(--shadow-soft);
}

.multi-filter-options {
  max-height: 14rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.multi-filter-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.45rem;
  border-radius: calc(var(--radius-sm) - 2px);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s ease;
}
.multi-filter-option:hover {
  background: var(--muted);
}
.multi-filter-option input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}
.multi-filter-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-filter-empty {
  padding: 0.75rem 0.5rem;
  font-size: 0.82rem;
  color: var(--muted-foreground);
  text-align: center;
}

.multi-filter-footer {
  display: flex;
  justify-content: flex-end;
  padding-top: 0.55rem;
  margin-top: 0.4rem;
  border-top: 1px solid var(--border);
}

.date-range-group {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.date-range-group input[type="date"] {
  width: auto;
  min-width: 9.5rem;
}
.date-range-sep {
  color: var(--muted-foreground);
  display: inline-flex;
  flex-shrink: 0;
}

.pill-nav {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.pill-nav a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.9rem;
  border-radius: 999px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.pill-nav a:hover {
  text-decoration: none;
  background: var(--secondary);
}
.pill-nav a.active {
  background: var(--primary);
  color: var(--primary-foreground);
}
.pill-nav a .pill-count {
  font-size: 0.72rem;
  opacity: 0.85;
  font-weight: 700;
}
.pill-nav a.active .pill-count {
  opacity: 1;
}

/* ---------------------------------------------------------------- pagination */

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding-top: 1.1rem;
  margin-top: 0.25rem;
}

.pagination-summary {
  font-size: 0.8rem;
  color: var(--muted-foreground);
}
.pagination-summary strong {
  color: var(--foreground);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pagination-page {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
}

/* -------------------------------------------------------- skeleton loading */

.skeleton-cell {
  display: inline-block;
  height: 0.85rem;
  border-radius: 0.3rem;
  width: 100%;
  background: linear-gradient(
    100deg,
    var(--skeleton-base) 30%,
    var(--skeleton-shine) 50%,
    var(--skeleton-base) 70%
  );
  background-size: 200% 100%;
  animation: admin-shimmer 1.3s ease-in-out infinite;
}

@keyframes admin-shimmer {
  0% {
    background-position: 150% 0;
  }
  100% {
    background-position: -50% 0;
  }
}

.requisitions-card.is-loading .table-wrap {
  position: relative;
}

#req-tbody tr {
  animation: admin-row-in 0.18s ease;
}

@keyframes admin-row-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ---------------------------------------------------------------- empty state */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 2.5rem 1rem;
  color: var(--muted-foreground);
  text-align: center;
}
.empty-state .icon {
  color: var(--border);
  width: 2.5rem;
  height: 2.5rem;
}

.coming-soon {
  padding: 3.5rem 1.5rem;
}
.coming-soon-icon {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklab, var(--accent) 14%, white);
  color: var(--primary);
  margin-bottom: 0.5rem;
}
.coming-soon h3 {
  color: oklch(0.22 0.05 250);
  margin-bottom: 0.15rem;
}
.coming-soon span {
  max-width: 26rem;
  margin-bottom: 1rem;
}

/* ---------------------------------------------------------------- accounts */

.account-search {
  width: 100%;
  max-width: 420px;
  margin-bottom: 1.5rem;
}
.account-search input {
  width: 100%;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.9rem;
}

.account-card {
  margin: 0;
}

.account-card-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.account-card-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in oklab, var(--ring) 45%, var(--border));
}

.account-card.active .account-card-btn {
  border-color: color-mix(in oklab, var(--emerald) 45%, var(--border));
  background: color-mix(in oklab, var(--emerald) 6%, white);
}

.account-card-icon {
  flex-shrink: 0;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in oklab, var(--primary) 12%, white);
  color: var(--primary);
}

.account-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.account-card-body strong {
  font-size: 0.92rem;
  color: oklch(0.2 0.05 250);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-card-body small {
  font-size: 0.76rem;
  color: var(--muted-foreground);
}

.account-card-arrow {
  color: var(--muted-foreground);
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- login */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at 15% 20%, oklch(0.4 0.12 220 / 55%), transparent 45%),
    radial-gradient(circle at 85% 80%, oklch(0.55 0.15 195 / 45%), transparent 50%),
    linear-gradient(160deg, var(--brand) 0%, #0a2a5c 55%, #124a7a 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-elevated);
  padding: 2.25rem 2rem;
  text-align: center;
  position: relative;
  z-index: 1;
}

.login-card .lock-badge {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 20px -6px color-mix(in oklab, var(--primary) 60%, transparent);
}

.login-brand {
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  color: var(--primary);
  margin-bottom: 0.75rem;
}
.login-brand em {
  font-style: normal;
  font-weight: 400;
  color: var(--muted-foreground);
}

.login-card h1 {
  font-size: 1.25rem;
  margin-bottom: 0.25rem;
}

.login-card p.subtitle {
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.login-card form {
  text-align: left;
}

/* ---------------------------------------------------------------- errors */

.error-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--background);
  text-align: center;
  padding: 2rem;
}

.error-page .code {
  font-size: 4rem;
  font-weight: 700;
  color: var(--brand);
  background: linear-gradient(135deg, var(--brand), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .sidebar,
  html.sidebar-collapsed .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main,
  html.sidebar-collapsed .main {
    margin-left: 0;
  }
  .menu-toggle {
    display: inline-flex;
  }
  .sidebar-collapse-toggle {
    display: none;
  }
  .brand-text,
  .sidebar-link-text {
    display: block;
  }
}

@media (max-width: 640px) {
  .account-badge-text {
    display: none;
  }
}
