:root {
  --ink: #171e1b;
  --ink-soft: #454f49;
  --muted: #616a64;
  --muted-light: #62695f;
  --paper: #f3f2ea;
  --card: #fbfaf5;
  --card-soft: #ebe9df;
  --line: #d7d5c8;
  --line-strong: #c3c1b2;
  --navy: #2c4257;
  --navy-soft: #35506a;
  --coral: #b23a2e;
  --coral-soft: #f3ded9;
  --blue: #35506a;
  --blue-soft: #e4eaee;
  --lime: #d8b15a;
  --lime-soft: #f3ead5;
  --violet: #6a5578;
  --violet-soft: #ece6f0;
  --green: #2f6b4f;
  --green-soft: #e1ece5;
  --amber: #8f6a2c;
  --amber-soft: #f3ead9;
  --red: #b23a2e;
  --red-soft: #f3ded9;
  --sidebar-width: 258px;
  --radius-sm: 2px;
  --radius: 3px;
  --radius-lg: 4px;
  --shadow-sm: 0 1px 0 var(--line);
  --shadow: 0 1px 0 var(--line), 0 10px 24px -18px rgba(27, 42, 35, .3);
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(79, 104, 223, .32);
  outline-offset: 3px;
}

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

svg {
  display: block;
}

[hidden],
[inert] {
  display: none !important;
}

code,
.mono {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 200;
  padding: 10px 14px;
  color: #fff;
  background: var(--navy);
  border-radius: 8px;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

/* Shared type and controls */
.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  line-height: 1.4;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: -.035em;
}

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button svg {
  width: 17px;
  height: 17px;
  fill: currentColor;
}

.button-busy-label {
  display: inline-flex;
  align-items: center;
}

.button-primary {
  color: #fff;
  background: var(--coral);
  border-color: var(--coral);
}

.button-primary:hover:not(:disabled) {
  background: #b23a2e;
  border-color: #b23a2e;
}

.button-dark {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.button-dark:hover:not(:disabled) {
  background: var(--navy-soft);
  border-color: var(--navy-soft);
}

.button-outline {
  color: var(--ink-soft);
  background: var(--card);
  border-color: var(--line-strong);
}

.button-outline:hover:not(:disabled) {
  border-color: var(--ink-soft);
}

.button-danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.button-success {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.button-small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 11px;
}

.button-full {
  width: 100%;
}

.text-button {
  padding: 0;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.text-button:hover {
  color: var(--coral);
}

.text-button-centered {
  display: block;
  margin: 14px auto 0;
  color: var(--muted);
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
  font-size: 18px;
}

.icon-button:hover {
  border-color: var(--line-strong);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  flex: 0 0 38px;
  color: var(--navy);
  background: var(--lime);
  border-radius: 11px 11px 4px 11px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -.08em;
}

.brand-mark-large {
  width: 52px;
  height: 52px;
  margin: 0 auto 20px;
  border-radius: 15px 15px 5px 15px;
  font-size: 16px;
}

.status-badge,
.nav-badge,
.source-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 23px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .06em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-active,
.status-delivered,
.status-approved,
.status-resolved,
.status-completed {
  color: #236d4d;
  background: var(--green-soft);
}

.status-idle,
.status-queued,
.status-processing,
.status-pending,
.status-partial {
  color: #8f5f18;
  background: var(--amber-soft);
}

.status-inactive,
.status-rejected,
.status-failed,
.status-bounced,
.status-denied,
.status-skipped {
  color: #a24441;
  background: var(--red-soft);
}

.status-new {
  color: #4c60c7;
  background: var(--blue-soft);
}

.status-blocked {
  color: #713e9b;
  background: var(--violet-soft);
}

.status-sent {
  color: #3d5ab8;
  background: var(--blue-soft);
}

.status-unknown {
  color: var(--muted);
  background: #edf0eb;
}

/* Authentication gate */
.auth-status-screen,
.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: var(--paper);
}

.auth-status-card,
.auth-card {
  width: min(100%, 470px);
  padding: clamp(27px, 5vw, 48px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-status-card {
  text-align: center;
}

.auth-status-card p {
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.loading-line {
  display: flex;
  justify-content: center;
  gap: 5px;
  margin-top: 20px;
}

.loading-line i {
  width: 7px;
  height: 7px;
  display: block;
  background: var(--coral);
  border-radius: 50%;
  animation: loading-pulse 1s infinite ease-in-out;
}

.loading-line i:nth-child(2) {
  animation-delay: .14s;
  background: var(--blue);
}

.loading-line i:nth-child(3) {
  animation-delay: .28s;
  background: var(--lime);
}

@keyframes loading-pulse {
  0%, 80%, 100% { opacity: .3; transform: scale(.8); }
  40% { opacity: 1; transform: scale(1); }
}

.auth-card {
  position: relative;
}

.auth-card-compact {
  width: min(100%, 430px);
}

.auth-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.auth-brand {
  margin-bottom: 39px;
}

.auth-brand strong,
.sidebar-brand strong {
  display: block;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -.025em;
}

.auth-brand small,
.sidebar-brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.auth-card h1 {
  max-width: 390px;
  margin: 9px 0 12px;
  font-size: clamp(27px, 5vw, 37px);
  line-height: 1.08;
}

.auth-intro {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.auth-intro code,
.notice code,
.toolbar-note code {
  padding: 2px 4px;
  color: var(--ink-soft);
  background: #eef1eb;
  border-radius: 4px;
  font-size: .9em;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 17px;
  padding: 12px 13px;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.55;
}

.notice p {
  margin: 0;
}

.notice-warning {
  color: #805a1b;
  background: var(--amber-soft);
  border: 1px solid #c9ac6a;
}

.notice-warning > span {
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  flex: 0 0 19px;
  color: #fff;
  background: var(--amber);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 900;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 19px;
  color: var(--muted-light);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--line);
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

.auth-form .optional {
  color: var(--muted-light);
  font-size: 9px;
  font-weight: 600;
}

.auth-form input,
.search-control input,
.select-control select,
.report-editor input,
.report-editor textarea,
.report-editor select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--card-soft);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  outline: 0;
  font-size: 12px;
}

.auth-form input:focus,
.search-control input:focus,
.select-control select:focus,
.report-editor input:focus,
.report-editor textarea:focus,
.report-editor select:focus {
  background: var(--card);
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(79, 104, 223, .12);
}

.auth-form .button {
  margin-top: 10px;
}

.otp-destination {
  margin: 0 0 5px;
  padding: 10px 12px;
  color: var(--muted);
  background: var(--blue-soft);
  border-radius: 9px;
  font-size: 11px;
}

.otp-destination strong {
  color: var(--ink-soft);
}

.auth-status {
  min-height: 18px;
  margin: 17px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.auth-status.is-error {
  color: var(--red);
}

.auth-status.is-success {
  color: var(--green);
}

.origin-note {
  margin: 25px 0 0;
  padding-top: 17px;
  color: var(--muted-light);
  border-top: 1px solid var(--line);
  font-size: 9px;
  line-height: 1.6;
}

.denied-user {
  display: grid;
  gap: 4px;
  margin: 0 0 22px;
  padding: 12px 14px;
  color: var(--muted);
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 10px;
}

.denied-user strong {
  color: var(--ink);
  font-size: 12px;
}

/* Admin shell */
.admin-app {
  min-height: 100vh;
}

.admin-shell {
  min-height: 100vh;
}

.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 25px 17px 18px;
  color: #eef3ed;
  background: var(--navy);
  overflow-y: auto;
}

.sidebar-brand {
  padding: 0 8px;
}

.sidebar-brand strong {
  color: #f3f7f1;
}

.sidebar-brand small {
  color: #87978e;
}

.sidebar-rule {
  height: 1px;
  margin: 25px 8px 22px;
  background: rgba(255, 255, 255, .1);
}

.sidebar-label {
  margin: 0 12px 9px;
  color: #7d8d84;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.admin-nav {
  display: grid;
  gap: 5px;
}

.admin-nav-item {
  position: relative;
  width: 100%;
  min-height: 47px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 0 12px;
  color: #aebbb3;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  text-align: left;
  transition: background-color .18s ease, color .18s ease;
}

.admin-nav-item::before {
  content: "";
  position: absolute;
  left: -17px;
  width: 3px;
  height: 22px;
  background: var(--coral);
  border-radius: 0 4px 4px 0;
  opacity: 0;
}

.admin-nav-item:hover,
.admin-nav-item.is-active {
  color: #fff;
  background: rgba(255, 255, 255, .08);
}

.admin-nav-item.is-active::before {
  opacity: 1;
}

.nav-icon {
  width: 22px;
  color: #9eafa4;
  font-size: 17px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
}

.admin-nav-item.is-active .nav-icon {
  color: var(--lime);
}

.admin-nav-item > span:nth-child(2) {
  font-size: 12px;
  font-weight: 700;
}

.nav-badge {
  min-width: 20px;
  min-height: 20px;
  padding: 2px 5px;
  color: #eaf2e9;
  background: rgba(255, 255, 255, .1);
  font-size: 8px;
}

.nav-badge.has-items {
  color: var(--navy);
  background: var(--lime);
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 25px;
}

.admin-identity {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  padding: 12px 8px;
  border-top: 1px solid rgba(255, 255, 255, .1);
}

.admin-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--coral);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 900;
}

.admin-identity strong,
.admin-identity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-identity strong {
  color: #f5f8f3;
  font-size: 11px;
}

.admin-identity small {
  margin-top: 3px;
  color: #82928a;
  font-size: 9px;
}

.sidebar-origin {
  margin: 16px 8px 14px;
  color: #73827a;
  font-size: 9px;
  line-height: 1.6;
}

.sidebar-signout {
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 10px 9px;
  color: #aebbb3;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 9px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.sidebar-signout:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, .3);
}

.admin-main {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  min-height: 84px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 16px clamp(22px, 3.5vw, 52px);
  background: rgba(243, 245, 240, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-heading {
  min-width: 0;
  flex: 1;
}

.topbar-heading h1 {
  margin: 4px 0 0;
  overflow: hidden;
  font-size: clamp(19px, 2.2vw, 25px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.sync-label {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.mobile-menu {
  width: 40px;
  height: 40px;
  display: none;
  place-items: center;
  color: var(--ink-soft);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
}

.mobile-menu svg {
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.admin-content {
  width: min(100%, 1530px);
  margin: 0 auto;
  padding: 31px clamp(22px, 3.5vw, 52px) 62px;
}

.admin-view {
  display: none;
}

.admin-view.is-active {
  display: block;
  animation: view-in .25s ease both;
}

@keyframes view-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.view-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 25px;
  margin: 5px 0 25px;
}

.view-heading h2 {
  margin: 7px 0 7px;
  font-size: clamp(27px, 3.2vw, 42px);
  line-height: 1.08;
}

.view-heading p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.view-date {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .13em;
  text-align: right;
  text-transform: uppercase;
}

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

.metric-card,
.summary-card {
  position: relative;
  min-height: 125px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 17px 18px;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -25px;
  bottom: -33px;
  width: 91px;
  height: 91px;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: .12;
}

.metric-top {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.metric-top span,
.summary-card span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.metric-top i {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 13px;
  font-style: normal;
  font-weight: 900;
}

.metric-card strong,
.summary-card strong {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 13px;
  font-family: var(--font-display);
  font-size: 29px;
  letter-spacing: -.06em;
  line-height: 1;
}

.metric-card small {
  position: relative;
  z-index: 1;
  display: block;
  margin-top: 8px;
  overflow: hidden;
  color: var(--muted-light);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-coral { color: var(--coral); }
.metric-coral .metric-top i { color: #a94238; background: var(--coral-soft); }
.metric-blue { color: var(--blue); }
.metric-blue .metric-top i { color: #4b5dc4; background: var(--blue-soft); }
.metric-lime { color: #769c28; }
.metric-lime .metric-top i { color: #517118; background: var(--lime-soft); }
.metric-violet { color: var(--violet); }
.metric-violet .metric-top i { color: #7049bd; background: var(--violet-soft); }
.metric-ink { color: var(--ink); }
.metric-ink .metric-top i { color: var(--ink); background: #e9eeea; }
.metric-green { color: var(--green); }
.metric-green .metric-top i { color: var(--green); background: var(--green-soft); }
.metric-amber { color: var(--amber); }
.metric-amber .metric-top i { color: #8f5f18; background: var(--amber-soft); }
.metric-slate { color: #64736b; }
.metric-slate .metric-top i { color: #5f6d66; background: #e9eeea; }

.compact-metrics {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 0;
}

.summary-card {
  min-height: 92px;
  padding: 15px 17px;
}

.summary-card strong {
  margin-top: 12px;
  font-size: 24px;
}

.panel {
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, .75fr);
  gap: 17px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 18px;
}

.panel-heading h3 {
  margin: 5px 0 0;
  font-size: 18px;
}

.activity-list,
.health-list,
.queue-list {
  display: grid;
  gap: 0;
}

.activity-row,
.health-row,
.queue-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.activity-row:first-child,
.health-row:first-child,
.queue-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.activity-copy,
.health-copy,
.queue-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.activity-copy strong,
.health-copy strong,
.queue-copy strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-copy small,
.health-copy small,
.queue-copy small {
  overflow: hidden;
  color: var(--muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-score {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
}

.health-value {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 800;
}

.health-value.is-warning {
  color: var(--amber);
}

.health-value.is-good {
  color: var(--green);
}

.source-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 17px;
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.source-panel h3 {
  margin: 6px 0 5px;
  color: #fff;
  font-size: 17px;
}

.source-panel p {
  max-width: 760px;
  margin: 0;
  color: #a7b5ad;
  font-size: 10px;
  line-height: 1.65;
}

.source-mark {
  width: 51px;
  height: 51px;
  display: grid;
  place-items: center;
  flex: 0 0 51px;
  color: var(--navy);
  background: var(--lime);
  border-radius: 15px 15px 5px 15px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 900;
}

/* Toolbars and tables */
.toolbar-panel {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 17px;
  padding: 15px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.search-control {
  position: relative;
  min-width: min(100%, 300px);
  flex: 1 1 260px;
}

.search-control input {
  height: 42px;
  padding-left: 35px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  color: var(--muted);
  font-size: 19px;
  line-height: 1;
  pointer-events: none;
  transform: translateY(-54%);
}

.select-control {
  min-width: 155px;
  display: grid;
  gap: 6px;
}

.select-control > span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.select-control select {
  height: 42px;
  padding-right: 30px;
}

.toolbar-note {
  margin: 0 0 11px auto;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  min-width: 850px;
  border-collapse: collapse;
  font-size: 11px;
}

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

.data-table th {
  color: var(--muted);
  background: var(--card-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background: #fbfcfa;
}

.learner-cell {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 180px;
}

.learner-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--lime-soft);
  border: 1px solid #d7e9a6;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 900;
}

.learner-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.learner-copy strong,
.learner-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.learner-copy strong {
  font-size: 11px;
}

.learner-copy small {
  color: var(--muted);
  font-size: 9px;
}

.number-cell {
  color: var(--ink-soft);
  font-weight: 800;
  white-space: nowrap;
}

.accuracy-cell {
  color: var(--ink);
  font-weight: 800;
  white-space: nowrap;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  border-top: 1px solid var(--line);
}

.pagination span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.state-box {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  padding: 28px 20px;
  color: var(--muted);
  text-align: center;
}

.state-box strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 14px;
}

.state-box p {
  max-width: 560px;
  margin: 0;
  font-size: 11px;
  line-height: 1.6;
}

.state-box.is-error {
  color: var(--red);
  background: #fffafa;
}

.state-box.is-empty {
  color: var(--muted);
  background: var(--card-soft);
}

.state-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--line);
  border-top-color: var(--coral);
  border-radius: 50%;
  animation: spin .8s ease-in-out infinite;
}

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

.state-retry {
  min-height: 34px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

/* Quiz analytics */
.quiz-filter-control {
  min-width: min(100%, 300px);
}

.quiz-table {
  min-width: 780px;
}

.quiz-name {
  display: grid;
  gap: 4px;
  min-width: 180px;
}

.quiz-name strong {
  font-size: 11px;
}

.quiz-name small {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 8px;
}

.progress-inline {
  min-width: 100px;
  display: grid;
  gap: 5px;
}

.progress-inline > span {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 800;
}

.progress-track {
  width: 100%;
  height: 5px;
  overflow: hidden;
  background: #e8ede7;
  border-radius: 5px;
}

.progress-track i {
  display: block;
  width: var(--value, 0%);
  height: 100%;
  background: var(--green);
  border-radius: inherit;
}

.leaderboard-panel {
  margin-top: 17px;
}

.leaderboard-panel .panel-heading {
  margin-bottom: 13px;
}

.small-muted {
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}

.leaderboard-list {
  display: grid;
  gap: 7px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 35px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--card-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.leaderboard-rank {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: var(--lime-soft);
  border-radius: 8px;
  font-size: 11px;
  font-weight: 900;
}

.leaderboard-name {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.leaderboard-name strong,
.leaderboard-name small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-name strong {
  font-size: 10px;
}

.leaderboard-name small {
  color: var(--muted);
  font-size: 8px;
}

.leaderboard-score {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

/* Reports */
.category-control {
  max-width: 260px;
}

.report-list {
  display: grid;
  gap: 12px;
}

.report-card {
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.report-card-head,
.report-card-meta,
.report-card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.report-card-head {
  justify-content: space-between;
}

.report-card-meta {
  margin-top: 9px;
  color: var(--muted);
  font-size: 9px;
}

.report-card-meta code {
  color: var(--ink-soft);
  font-size: 9px;
}

.report-card h3 {
  margin: 14px 0 7px;
  font-size: 16px;
}

.report-card h3 code {
  color: var(--ink);
  font-size: .78em;
}

.report-question {
  margin: 0 0 9px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.55;
}

.report-question strong {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.report-detail {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.report-source {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.report-source strong {
  color: var(--ink-soft);
}

.report-card-actions {
  margin-top: 17px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.report-card-actions .select-control {
  min-width: 145px;
}

.report-editor {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px dashed var(--line-strong);
}

.report-editor summary,
.optional-editor summary {
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 10px;
  font-weight: 800;
}

.report-editor[open] summary,
.optional-editor[open] summary {
  margin-bottom: 13px;
}

.report-editor-grid {
  display: grid;
  grid-template-columns: minmax(170px, .65fr) minmax(240px, 1.35fr);
  gap: 11px;
}

.report-editor label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.report-editor textarea {
  min-height: 76px;
  padding: 10px 12px;
  resize: vertical;
}

.report-editor .button {
  margin-top: 12px;
}

.editor-help {
  margin: 7px 0 0;
  color: var(--muted-light);
  font-size: 9px;
  line-height: 1.5;
}

/* Testimonials */
.tab-toolbar {
  align-items: center;
  padding: 6px;
}

.tab-button {
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
}

.tab-button b {
  margin-left: 5px;
  color: var(--muted-light);
  font-size: 9px;
}

.tab-button:hover,
.tab-button.is-active {
  color: var(--ink);
  background: var(--card-soft);
}

.tab-button.is-active b {
  color: var(--coral);
}

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

.testimonial-card {
  display: flex;
  flex-direction: column;
  min-height: 190px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.testimonial-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.testimonial-person {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.testimonial-person strong {
  font-size: 12px;
}

.testimonial-person small {
  color: var(--muted);
  font-size: 9px;
}

.testimonial-rating {
  color: var(--amber);
  font-size: 12px;
  letter-spacing: .08em;
  white-space: nowrap;
}

.testimonial-message {
  flex: 1;
  margin: 16px 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.7;
}

.testimonial-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.testimonial-date {
  color: var(--muted-light);
  font-size: 9px;
}

.testimonial-actions {
  display: flex;
  gap: 6px;
}

/* Notifications */
.notification-table {
  min-width: 820px;
}

.recipient-cell {
  display: grid;
  gap: 3px;
  min-width: 170px;
}

.recipient-cell strong,
.recipient-cell small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recipient-cell strong {
  font-size: 10px;
}

.recipient-cell small {
  color: var(--muted);
  font-size: 8px;
}

.provider-cell {
  max-width: 250px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.provider-cell.is-error {
  color: var(--red);
}

/* Feedback */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 44px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: #fff;
  background: var(--navy);
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 11px;
  box-shadow: var(--shadow);
  animation: toast-in .22s ease both;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.toast-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: var(--navy);
  background: var(--lime);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 900;
}

.toast p {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
}

.noscript-message {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 30px;
  color: #fff;
  background: var(--navy);
  font-size: 14px;
  text-align: center;
}

/* Responsive behavior */
@media (max-width: 1180px) {
  :root { --sidebar-width: 226px; }
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .overview-grid { grid-template-columns: 1fr; }
  .testimonial-list { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .admin-sidebar {
    visibility: hidden;
    transform: translateX(-100%);
    transition: transform .22s ease, visibility .22s ease;
    box-shadow: var(--shadow);
  }

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

  .admin-main {
    margin-left: 0;
  }

  .mobile-menu {
    display: grid;
  }

  .admin-topbar {
    padding-left: 18px;
    padding-right: 18px;
  }

  .admin-content {
    padding-right: 18px;
    padding-left: 18px;
  }

  .topbar-actions .sync-label {
    display: none;
  }
}

@media (max-width: 650px) {
  .auth-status-screen,
  .auth-screen {
    padding: 15px;
  }

  .auth-status-card,
  .auth-card {
    padding: 27px 21px;
    border-radius: 17px;
  }

  .auth-brand {
    margin-bottom: 30px;
  }

  .admin-topbar {
    min-height: 72px;
    gap: 10px;
  }

  .topbar-heading h1 {
    font-size: 18px;
  }

  .topbar-actions .button {
    width: 36px;
    min-height: 36px;
    padding: 0;
    font-size: 0;
  }

  .topbar-actions .button span {
    font-size: 17px;
  }

  .topbar-actions .icon-button {
    display: none;
  }

  .admin-content {
    padding: 24px 13px 45px;
  }

  .view-heading {
    display: block;
    margin-bottom: 20px;
  }

  .view-heading h2 {
    font-size: 29px;
  }

  .view-date {
    display: block;
    margin-top: 13px;
    text-align: left;
  }

  .metric-grid,
  .compact-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }

  .metric-card {
    min-height: 111px;
    padding: 14px;
  }

  .metric-card strong {
    font-size: 25px;
  }

  .metric-card small {
    font-size: 8px;
  }

  .panel {
    padding: 16px;
  }

  .panel-heading {
    align-items: flex-start;
  }

  .panel-heading h3 {
    font-size: 16px;
  }

  .source-panel {
    align-items: flex-start;
  }

  .source-mark {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
    font-size: 12px;
  }

  .toolbar-panel {
    align-items: stretch;
    padding: 12px;
  }

  .search-control,
  .select-control,
  .quiz-filter-control,
  .category-control {
    width: 100%;
    max-width: none;
    min-width: 0;
    flex: 1 1 100%;
  }

  .toolbar-note {
    width: 100%;
    margin: 2px 0 0;
  }

  .tab-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  .tab-button {
    flex: 0 0 auto;
  }

  .report-editor-grid {
    grid-template-columns: 1fr;
  }

  .report-card-actions {
    align-items: stretch;
  }

  .report-card-actions .select-control {
    flex: 1 1 130px;
  }

  .report-card-actions .button {
    flex: 1 1 130px;
  }

  .testimonial-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .toast {
    right: 13px;
    bottom: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------------------------------- Question ingest ---------------------------------- */

.ingest-upload-panel { display: grid; gap: 14px; }

.ingest-drop {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 34px 20px;
  text-align: center;
  background: var(--card-soft);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  transition: border-color .15s ease, background .15s ease;
}

.ingest-drop.is-dragover {
  background: var(--blue-soft);
  border-color: var(--blue);
}

.ingest-drop p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.6; }
.ingest-drop p strong { color: var(--ink); font-size: 13px; }
.ingest-drop-note { max-width: 520px; }

.ingest-browse,
.ingest-template-link {
  padding: 0;
  color: var(--navy);
  background: none;
  border: 0;
  border-bottom: 1px solid var(--navy);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
}

.ingest-file-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card-soft);
  border-radius: var(--radius);
}

.ingest-file-row > div { flex: 1 1 220px; min-width: 0; }
.ingest-file-row strong { display: block; overflow: hidden; font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.ingest-file-row small { color: var(--muted); font-size: 9.5px; }
.ingest-label-control { flex: 1 1 220px; min-width: 200px; }
.ingest-label-control input { height: 38px; padding: 0 12px; }

.ingest-results-panel { display: grid; gap: 15px; }

.ingest-tabs { display: flex; gap: 4px; padding: 5px; background: var(--card-soft); border-radius: 10px; }
.ingest-tabs .tab-button { flex: 1; }

.ingest-row-list { display: grid; gap: 9px; }

.ingest-row {
  padding: 13px 15px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.ingest-row-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.ingest-row-ref { color: var(--muted); font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.ingest-row-question { flex: 1 1 260px; min-width: 0; margin: 8px 0 0; overflow: hidden; font-size: 12.5px; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.ingest-row.is-open .ingest-row-question { overflow: visible; white-space: pre-wrap; }

.ingest-row-issues { display: grid; gap: 5px; margin: 9px 0 0; padding: 0; list-style: none; font-size: 11px; }
.ingest-row-issues li { padding-left: 15px; position: relative; line-height: 1.5; }
.ingest-row-issues li::before { position: absolute; left: 0; content: '•'; }
.ingest-row-issues li.is-error { color: #a4372c; }
.ingest-row-issues li.is-warn { color: #8f5f18; }
.ingest-row-issues .ingest-apply-suggestion { margin-left: 8px; color: var(--navy); background: none; border: 0; border-bottom: 1px solid var(--navy); cursor: pointer; font: inherit; font-size: 10.5px; font-weight: 700; }

.ingest-row-toggle {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 4px 10px;
  color: var(--muted);
  background: var(--card-soft);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.ingest-row-editor { display: none; grid-template-columns: minmax(150px, .55fr) minmax(220px, 1.45fr); gap: 10px; margin-top: 13px; padding-top: 13px; border-top: 1px dashed var(--line-strong); }
.ingest-row.is-open .ingest-row-editor { display: grid; }

.ingest-row-editor label {
  display: grid;
  gap: 5px;
  align-content: start;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.ingest-row-editor input,
.ingest-row-editor select,
.ingest-row-editor textarea {
  padding: 8px 10px;
  color: var(--ink);
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
}

.ingest-row-editor textarea { min-height: 56px; resize: vertical; }
.ingest-row-editor .ingest-options-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

.ingest-batch-row td:first-child strong { display: block; font-size: 12px; }
.ingest-batch-row td:first-child small { color: var(--muted); font-size: 9.5px; }
#otpRequestForm, #otpVerifyForm { display: none !important; }
