*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg: #edf1f5;
  --sidebar: #202522;
  --sidebar-soft: #2b3430;
  --surface: #ffffff;
  --surface-soft: #f6f8fa;
  --text: #111827;
  --muted: #667085;
  --line: rgba(17, 24, 39, 0.12);
  --line-strong: rgba(17, 24, 39, 0.2);
  --blue: #1f5eff;
  --blue-dark: #1747bf;
  --green: #147a55;
  --amber: #a35c00;
  --red: #b42318;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html {
  min-height: 100%;
  background: var(--bg);
}

html::before {
  content: "";
  position: fixed;
  inset: 0 auto 0 0;
  width: 280px;
  background: var(--sidebar);
  pointer-events: none;
}

body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

body.modal-scroll-locked {
  overflow: hidden;
  overscroll-behavior: none;
}

button, a, select {
  font: inherit;
}

button, select {
  color: inherit;
}

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

.desktop-sidebar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 24px 18px;
  background: var(--sidebar);
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 790;
  text-decoration: none;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.sidebar-nav a {
  min-height: 38px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 0.93rem;
  font-weight: 700;
  text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.is-active {
  background: var(--sidebar-soft);
  color: #ffffff;
}

.sidebar-card,
.admin-box {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
}

.sidebar-card span,
.sidebar-card small,
.admin-box label,
.admin-box p {
  color: #cbd5e1;
  font-size: 0.78rem;
}

.sidebar-card strong {
  overflow-wrap: anywhere;
  font-size: 1rem;
}

.admin-box[hidden] {
  display: none;
}

.admin-box select {
  width: 100%;
  min-height: 38px;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 8px;
  background: #0f172a;
  color: #ffffff;
  padding: 7px 9px;
}

.sidebar-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  color: #94a3b8;
  font-size: 0.68rem;
  font-weight: 760;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.main-panel {
  min-width: 0;
  padding: 26px;
}

.mobile-topbar {
  display: none;
}

.desktop-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

.title-line {
  display: flex;
  align-items: baseline;
  min-width: 0;
}

.desktop-topbar h1,
.mobile-topbar h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: 0;
}

.desktop-topbar p,
.mobile-topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.topbar-actions {
  --topbar-control-height: 44px;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.mobile-actions {
  --topbar-control-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.scope-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-control-height);
  min-height: var(--topbar-control-height);
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
  white-space: nowrap;
}

.scope-toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--blue);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 790;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.14;
  letter-spacing: 0;
}

h2 {
  font-size: 1.18rem;
}

h3 {
  font-size: 0.92rem;
}

.status-band {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-control-height);
  min-height: var(--topbar-control-height);
  max-width: 260px;
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  box-shadow: none;
}

.mobile-auth-band {
  display: none;
}

.status-band p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-band[data-login-visible="true"] {
  max-width: 360px;
  padding: 0 10px;
}

.status-band[data-login-visible="true"] p {
  overflow: hidden;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-content {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.auth-content p {
  flex: 1 1 auto;
  min-width: 0;
}

.telegram-login-button[hidden] {
  display: none;
}

.telegram-login-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  gap: 6px;
  height: 32px;
  min-width: 74px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  background: #2790d8;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 790;
  line-height: 1.15;
  white-space: nowrap;
  cursor: pointer;
}

.telegram-login-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: currentColor;
}

.telegram-login-button span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.telegram-login-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.status-band[data-tone="ok"] {
  color: var(--green);
  border-color: rgba(20, 122, 85, 0.24);
}

.status-band[data-tone="warning"] {
  color: var(--amber);
  border-color: rgba(163, 92, 0, 0.26);
}

.status-band[data-tone="error"] {
  color: var(--red);
  border-color: rgba(180, 35, 24, 0.24);
}

.pulse {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: currentColor;
}

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

.metrics article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metrics article {
  min-width: 0;
  min-height: 72px;
  padding: 12px 14px;
}

.metrics span,
dt {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.metrics strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 1.32rem;
  line-height: 1.08;
}

.panel-subtitle {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}

.panel-subtitle {
  margin: 4px 0 0;
}

.desktop-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto auto;
  gap: 16px;
  align-items: start;
}

.panel {
  margin-bottom: 16px;
  padding: 16px;
}

.desktop-grid > .panel {
  margin-bottom: 0;
}

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

.panel-heading-with-control {
  align-items: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 750;
}

.profile-panel {
  padding: 20px;
}

.alerts-panel {
  align-self: start;
  display: flex;
  min-height: 0;
  flex-direction: column;
  grid-column: 2;
  grid-row: 1 / 3;
}

.sources-panel {
  align-self: start;
  container-type: inline-size;
  display: flex;
  min-height: 0;
  flex-direction: column;
  grid-column: 1;
  grid-row: 2;
}

.profile-heading {
  align-items: flex-start;
  margin-bottom: 16px;
}

.profile-heading h2 {
  overflow-wrap: anywhere;
  font-size: 1.42rem;
  line-height: 1.12;
}

.profile-brief {
  display: grid;
  gap: 8px;
}

.profile-brief-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.profile-brief-heading h3 {
  margin: 0;
}

.profile-brief-open {
  height: 28px;
  min-height: 28px;
  padding: 0 10px;
  font-size: 0.76rem;
}

.profile-brief .summary {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.profile-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin: 0 0 18px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.profile-status div {
  min-width: 0;
}

.profile-status dt,
.profile-section h3,
.profile-brief h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 780;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.profile-status dd {
  margin: 3px 0 0;
}

.profile-status-primary dd {
  color: var(--text);
  font-size: 1.03rem;
  font-weight: 760;
  line-height: 1.24;
}

.profile-status div:not(.profile-status-primary) {
  text-align: right;
}

.profile-status div:not(.profile-status-primary) dd {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

.profile-body {
  display: grid;
  gap: 16px;
}

.profile-section {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.profile-badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
}

.profile-line {
  width: fit-content;
  max-width: 100%;
  margin: 0;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
}

.binary-badge {
  width: fit-content;
  max-width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.2;
}

.binary-badge[data-remote="yes"] {
  border-color: rgba(20, 122, 85, 0.18);
  background: rgba(20, 122, 85, 0.1);
  color: var(--green);
}

.binary-badge[data-remote="no"] {
  border-color: rgba(180, 35, 24, 0.18);
  background: rgba(180, 35, 24, 0.08);
  color: var(--red);
}

.binary-badge[data-remote="unknown"] {
  color: var(--muted);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-weight: 700;
}

.tag-list span {
  min-width: 0;
  max-width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.profile-brief {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.profile-brief .summary {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

.dialog-version {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.detail-grid div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 720;
}

.summary {
  display: -webkit-box;
  margin: 0 0 14px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.52;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

.primary-action,
.secondary-action,
.icon-button {
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.primary-action {
  width: 100%;
  min-height: 48px;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-weight: 780;
}

.compact-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: var(--topbar-control-height);
  min-height: var(--topbar-control-height);
  min-width: 118px;
  padding: 0 16px;
}

.secondary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--topbar-control-height);
  min-height: var(--topbar-control-height);
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 730;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-weight: 760;
}

.icon-button.small {
  width: 34px;
  height: 34px;
  font-size: 0.78rem;
}

.primary-action:not(:disabled):hover {
  background: var(--blue-dark);
}

.secondary-action:not(:disabled):hover,
.icon-button:not(:disabled):hover {
  border-color: var(--line-strong);
  background: #f9fafb;
}

.icon-button:disabled,
.primary-action:disabled,
.secondary-action:disabled {
  cursor: wait;
  opacity: 0.56;
}

.mobile-run {
  display: none;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pager span {
  min-width: 74px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 720;
  text-align: center;
}

.alert-list {
  display: grid;
  align-content: start;
  gap: 7px;
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  padding-right: 0;
}

.alert-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 58px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.alert-row:hover {
  border-color: rgba(31, 94, 255, 0.28);
  background: #ffffff;
}

.alert-row[data-applied="true"],
.source-job-row[data-applied="true"] {
  border-color: rgba(20, 122, 85, 0.34);
  outline: 2px solid rgba(20, 122, 85, 0.34);
  background: rgba(20, 122, 85, 0.08);
}

.alert-row[data-applied="true"]:hover,
.source-job-row[data-applied="true"]:hover {
  border-color: rgba(20, 122, 85, 0.5);
  outline-color: rgba(20, 122, 85, 0.5);
  background: rgba(20, 122, 85, 0.11);
}

.alert-main {
  min-width: 0;
}

.alert-main strong {
  display: block;
  overflow: hidden;
  font-size: 0.98rem;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-main strong {
  display: block;
  overflow: hidden;
  font-size: 0.98rem;
  line-height: 1.22;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-main {
  min-width: 0;
}

.alert-main span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-main span {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-cell {
  display: grid;
  align-content: center;
  gap: 5px;
}

.score-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
}

.score-track {
  height: 6px;
  overflow: hidden;
  border-radius: 8px;
  background: #e5e7eb;
}

.score-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--score-color, var(--blue));
}

.source-list {
  display: grid;
  gap: 8px;
  flex: 0 0 auto;
  min-height: 0;
  overflow: visible;
  padding-right: 0;
}

.source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 104px;
  gap: 10px;
  align-items: center;
  min-height: 58px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.source-row:hover,
.source-job-row:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.status-pill {
  align-self: center;
  width: 100%;
  min-width: 0;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 780;
  text-align: center;
}

.status-pill[data-status="success"] {
  background: rgba(20, 122, 85, 0.14);
  color: #0f6b49;
}

.status-pill[data-status="active"] {
  background: rgba(20, 122, 85, 0.12);
  color: #0f6b49;
}

.status-pill[data-status="active_matches"] {
  background: rgba(31, 94, 255, 0.1);
  color: var(--blue);
}

.status-pill[data-status="missing"] {
  background: rgba(163, 92, 0, 0.1);
  color: var(--amber);
}

.status-pill[data-status="closed"] {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
}

.status-pill[data-status="stale_cache"],
.status-pill[data-status="no_cache"] {
  background: rgba(163, 92, 0, 0.1);
  color: var(--amber);
}

.status-pill[data-status="failed"],
.status-pill[data-status="error"] {
  background: rgba(180, 35, 24, 0.1);
  color: var(--red);
}

.empty {
  margin: 0;
  color: var(--muted);
}

.loading-state {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
}

.loading-state p {
  margin: 0;
  font-weight: 720;
}

.spinner {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border: 2px solid #d6dde6;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.source-dialog,
.job-dialog,
.admin-job-dialog,
.profile-brief-dialog {
  position: fixed;
  inset: 14px;
  width: min(760px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 28px));
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.28);
}

@supports (height: 100dvh) {
  .source-dialog,
  .job-dialog,
  .admin-job-dialog,
  .profile-brief-dialog {
    max-height: min(820px, calc(100dvh - 28px));
  }
}

.source-dialog {
  width: min(860px, calc(100vw - 28px));
}

.job-dialog {
  overflow: auto;
  scrollbar-gutter: stable;
}

.admin-job-dialog {
  width: min(1040px, calc(100vw - 28px));
}

.source-dialog::backdrop,
.job-dialog::backdrop,
.admin-job-dialog::backdrop,
.profile-brief-dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
}

.source-dialog article,
.job-dialog article,
.admin-job-dialog article,
.profile-brief-dialog article {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.job-dialog article {
  position: relative;
  overflow: clip;
}

.dialog-nav-zone {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  width: 33.333%;
  padding: 0;
  border: 0;
  background: transparent;
  opacity: 1;
  cursor: pointer;
  touch-action: pan-y;
}

.job-dialog article::before,
.job-dialog article::after {
  position: absolute;
  top: 50%;
  z-index: 0;
  color: rgba(17, 24, 39, 0.075);
  font-size: clamp(6rem, 15vw, 11rem);
  font-weight: 760;
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.38);
  transform: translateY(-50%);
}

.job-dialog article::before {
  left: 24px;
  content: "‹";
}

.job-dialog article::after {
  right: 24px;
  content: "›";
}

.dialog-nav-zone:disabled {
  cursor: default;
}

.dialog-nav-zone:focus,
.dialog-nav-zone:focus-visible {
  outline: none;
}

.dialog-nav-zone-previous {
  left: 0;
}

.dialog-nav-zone-next {
  right: 0;
}

.job-dialog article > * {
  position: relative;
  z-index: 1;
}

.job-dialog .dialog-header,
.job-dialog .dialog-actions {
  z-index: 3;
}

.profile-brief-full {
  max-height: min(620px, calc(100vh - 180px));
  margin: 0;
  overflow: auto;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.source-job-list {
  display: grid;
  gap: 8px;
  max-height: min(620px, calc(100vh - 180px));
  overflow: auto;
}

.source-job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px);
  gap: 12px;
  align-items: center;
  min-height: 58px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.dialog-header .icon-button.small {
  flex: 0 0 34px;
}

.dialog-header p {
  margin: 6px 0 0;
  color: var(--muted);
}

.dialog-score {
  display: grid;
  gap: 8px;
}

.dialog-score span {
  color: var(--muted);
  font-weight: 760;
}

.dialog-score .dialog-score-date {
  font-weight: 400;
}

.dialog-section,
.dialog-columns {
  display: grid;
  gap: 8px;
}

.dialog-section p,
.dialog-section ul,
.dialog-columns ul {
  margin: 0;
  color: var(--muted);
}

.dialog-section ul {
  padding-left: 18px;
}

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

.dialog-columns ul {
  padding-left: 18px;
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.applied-action[data-applied="true"] {
  border-color: rgba(20, 122, 85, 0.34);
  outline: 2px solid rgba(20, 122, 85, 0.22);
  background: rgba(20, 122, 85, 0.1);
  color: var(--green);
}

.admin-grid[hidden] {
  display: none;
}

[data-dashboard-workspace][hidden] {
  display: none;
}

.admin-grid {
  display: block;
  height: 100%;
  margin-top: 0;
}

.main-panel.admin-mode {
  height: 100vh;
  padding: 0;
  overflow: hidden;
}

.main-panel.admin-mode .admin-grid > .panel {
  height: 100vh;
  margin-bottom: 0;
  border-radius: 0;
  box-shadow: none;
}

.admin-jobs-panel {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

.admin-jobs-panel[hidden],
.admin-evaluation-panel[hidden] {
  display: none;
}

.admin-evaluation-panel {
  min-height: 0;
}

.admin-panel-heading {
  align-items: center;
  margin-bottom: 10px;
}

.admin-panel-heading > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.admin-panel-heading .eyebrow,
.admin-panel-heading h2,
.admin-panel-heading .panel-subtitle {
  margin: 0;
  white-space: nowrap;
}

.admin-panel-heading .eyebrow,
.admin-panel-heading h2 {
  color: var(--text);
  font-size: 0.74rem;
  font-weight: 790;
  line-height: 1.14;
}

.admin-panel-heading .eyebrow::after {
  margin-left: 10px;
  color: var(--line-strong);
  content: "/";
}

.admin-panel-heading .panel-subtitle {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
}

.admin-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(168px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.admin-filters label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.admin-filters label span {
  position: relative;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 780;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.admin-filters [data-tooltip] {
  cursor: help;
}

.admin-filters [data-tooltip]::after {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 5;
  display: none;
  width: max-content;
  max-width: 260px;
  padding: 7px 8px;
  border: 1px solid #334155;
  border-radius: 6px;
  background: #0f172a;
  color: #f8fafc;
  content: attr(data-tooltip);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0;
  line-height: 1.35;
  text-transform: none;
  white-space: normal;
}

.admin-filters [data-tooltip]:hover::after,
.admin-filters [data-tooltip]:focus-visible::after {
  display: block;
}

.admin-filters input,
.admin-filters select {
  box-sizing: border-box;
  width: 100%;
  height: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 9px;
  color: var(--text);
  font: inherit;
}

.admin-check {
  align-self: end;
  align-content: center;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  height: 38px;
  padding-bottom: 0;
}

.admin-check input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--blue);
}

.admin-filter-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.admin-filter-actions .secondary-action,
.admin-filter-actions .primary-action {
  height: 32px;
  min-height: 32px;
  min-width: 78px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.admin-filter-pager {
  grid-column: 6;
  justify-content: end;
  align-self: end;
  height: 32px;
}

.admin-filter-pager .icon-button.small {
  width: 32px;
  height: 32px;
}

.admin-evaluation-form {
  grid-template-columns: minmax(180px, 260px) minmax(260px, 1fr) auto;
}

.admin-evaluation-result {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.admin-evaluation-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.admin-evaluation-card h3 {
  margin: 2px 0 5px;
  font-size: 0.95rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.admin-evaluation-card p:last-child {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 680;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.admin-evaluation-result .admin-text-block {
  grid-column: 1 / -1;
}

.admin-job-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  padding-right: 2px;
}

.admin-job-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.74rem;
}

.admin-job-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 780;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.admin-job-table td {
  max-width: 280px;
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  line-height: 1.25;
  vertical-align: middle;
}

.admin-job-row {
  cursor: pointer;
  outline: none;
}

.admin-job-row:hover,
.admin-job-row[data-selected="true"] {
  background: #f8fafc;
}

.admin-job-row:focus-visible {
  outline: 3px solid rgba(31, 94, 255, 0.24);
  outline-offset: -3px;
}

.admin-job-title-cell {
  min-width: 0;
}

.admin-job-title-cell strong {
  display: block;
  overflow: hidden;
  max-width: 420px;
  font-size: 0.76rem;
  font-weight: 760;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-job-title-cell span {
  display: block;
  margin-top: 1px;
  overflow: hidden;
  max-width: 420px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.62rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-job-table td:not(.admin-job-title-cell) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-num-cell,
.admin-date-cell {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.admin-job-table .status-pill {
  width: fit-content;
  min-width: 54px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.68rem;
  line-height: 1.2;
}

.admin-job-detail {
  display: grid;
  gap: 10px;
  max-height: min(680px, calc(100vh - 150px));
  overflow: auto;
  padding-right: 2px;
}

.admin-attribute-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0;
}

.admin-attribute-grid div {
  position: relative;
  min-width: 0;
  padding: 6px 42px 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.admin-attribute-grid dt {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 720;
}

.admin-attribute-grid dd {
  max-height: 66px;
  margin: 0;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.74rem;
  font-weight: 500;
  line-height: 1.35;
  white-space: pre-wrap;
}

.admin-action-attribute dd {
  max-height: none;
  overflow: visible;
}

.admin-action-attribute .primary-action,
.admin-action-attribute .secondary-action {
  width: 100%;
  height: 22px;
  min-height: 22px;
  min-width: 0;
  padding: 0 8px;
  font-size: 0.72rem;
  line-height: 1;
}

.admin-action-attribute .secondary-action[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.56;
}

.admin-copy-button {
  position: absolute;
  top: 6px;
  right: 7px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  opacity: 0.32;
  text-transform: uppercase;
}

.admin-copy-button:hover,
.admin-copy-button:focus-visible {
  opacity: 0.9;
}

.admin-tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-height: none;
  overflow: visible;
  white-space: normal;
}

.admin-tag-list span {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #e8eef4;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.68rem;
  font-weight: 720;
}

.admin-text-block {
  position: relative;
  display: grid;
  gap: 3px;
}

.admin-text-block .admin-copy-button {
  top: 28px;
  right: 10px;
}

.admin-text-block h3 {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 780;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.admin-text-block pre {
  min-height: 120px;
  max-height: 360px;
  margin: 0;
  overflow: auto;
  padding: 10px 48px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 940px) {
  html::before {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .desktop-sidebar,
  .desktop-topbar {
    display: none;
  }

  .main-panel {
    width: min(100%, 940px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 14px;
  }

  .main-panel.admin-mode {
    height: auto;
    min-height: 100vh;
    padding: 14px;
    overflow: visible;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
  }

  .mobile-topbar h1 {
    font-size: 1.65rem;
  }

  .mobile-auth-band {
    --topbar-control-height: 44px;
    display: flex;
    width: 100%;
    max-width: none;
    margin-bottom: 12px;
  }

  .mobile-auth-band[data-login-visible="true"] {
    max-width: none;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
  }

  .desktop-grid {
    display: block;
    height: auto;
    min-height: 0;
  }

  .desktop-grid > .panel {
    margin-bottom: 14px;
  }

  .admin-grid {
    display: block;
    height: auto;
  }

  .admin-grid > .panel {
    margin-bottom: 14px;
  }

  .main-panel.admin-mode .admin-grid > .panel {
    height: auto;
    border-radius: 8px;
    box-shadow: var(--shadow);
  }

  .admin-job-list {
    max-height: none;
    overflow: visible;
  }

  .admin-filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .alert-list,
  .source-list {
    overflow: visible;
    padding-right: 0;
  }

  .mobile-run {
    display: block;
  }

  .alerts-panel {
    margin-bottom: 14px;
  }
}

@media (max-width: 620px) {
  .panel {
    padding: 14px;
  }

  .detail-grid,
  .dialog-columns {
    grid-template-columns: 1fr;
  }

  .alert-row,
  .source-job-row,
  .source-row {
    grid-template-columns: 1fr;
  }

  .admin-filters,
  .admin-evaluation-result,
  .admin-attribute-grid,
  .admin-detail-header {
    grid-template-columns: 1fr;
  }

  .source-row {
    align-items: start;
  }

  .status-pill {
    width: fit-content;
  }
}
