:root {
  color-scheme: light;
  --navy: #062b57;
  --navy-dark: #031d3c;
  --blue: #155eef;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --line: #e4e7ec;
  --text: #101828;
  --muted: #667085;
  --green: #12b76a;
  --green-bg: #ecfdf3;
  --amber: #f79009;
  --amber-bg: #fffaeb;
  --red: #f04438;
  --red-bg: #fef3f2;
  --blue-bg: #eff8ff;
  --shadow: 0 16px 38px rgba(16, 24, 40, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

a {
  color: var(--navy);
  text-decoration: none;
  font-weight: 700;
}

button,
input,
textarea {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 18px;
  background: linear-gradient(180deg, var(--navy-dark), #052a54 68%, #03192f);
  color: #ffffff;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 0 12px 18px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  font-size: 30px;
}

.brand strong {
  display: block;
  font-size: 21px;
  line-height: 0.95;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.brand span {
  display: block;
  margin-top: 8px;
  color: #47d5b0;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 0 16px;
  color: rgba(255, 255, 255, 0.92);
  border-radius: 7px;
  font-weight: 750;
}

.side-nav a.active,
.side-nav a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.side-nav span {
  width: 22px;
  text-align: center;
  font-size: 18px;
}

.workspace-card,
.account-card {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding: 20px 12px 0;
}

.workspace-card {
  margin-top: auto;
}

.workspace-card strong,
.account-card strong {
  display: block;
  font-size: 14px;
}

.workspace-card span,
.account-card span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logout-link {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.72);
  font-size: 18px;
}

.avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #d9e7ff;
  color: var(--navy);
  font-weight: 900;
}

.content {
  min-width: 0;
  overflow-x: clip;
  padding: 28px 38px 44px;
}

.mobile-topbar {
  display: none;
}

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

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

h1 {
  margin-bottom: 8px;
  font-size: 26px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.dashboard-header p,
.muted {
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.last-check {
  display: grid;
  gap: 3px;
  min-width: 170px;
  color: var(--muted);
  font-size: 12px;
}

.last-check strong {
  color: var(--text);
  font-size: 13px;
}

.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
}

.status-pill.success {
  color: #067647;
  background: var(--green-bg);
  border-color: #abefc6;
}

.status-pill.warning {
  color: #b54708;
  background: var(--amber-bg);
  border-color: #fedf89;
}

.status-pill.error {
  color: #b42318;
  background: var(--red-bg);
  border-color: #fecdca;
}

.status-pill.info {
  color: var(--blue);
  background: var(--blue-bg);
  border-color: #bfdbfe;
}

.badge {
  color: #b54708;
  background: var(--amber-bg);
  border-color: #fedf89;
}

.success-badge {
  color: #067647;
  background: var(--green-bg);
  border-color: #abefc6;
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--navy);
  background: var(--surface);
  cursor: pointer;
  font-weight: 900;
}

.run-now button,
.primary-button,
.secondary-button.filled {
  border: 0;
  border-radius: 7px;
  background: var(--navy);
  color: #ffffff;
  cursor: pointer;
  font-weight: 850;
}

.run-now button {
  min-width: 210px;
  min-height: 62px;
  display: grid;
  grid-template-columns: 20px 1fr;
  column-gap: 8px;
  align-items: center;
  padding: 10px 18px;
  text-align: left;
}

.run-now span {
  grid-row: span 2;
}

.run-now small {
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.metric-card,
.panel {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  position: relative;
  min-height: 152px;
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 14px;
  padding: 22px;
  overflow: hidden;
}

.metric-card h2 {
  margin-bottom: 8px;
  font-size: 13px;
}

.metric-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 30px;
  line-height: 1;
}

.metric-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.metric-card a {
  align-self: end;
  grid-column: 2;
}

.metric-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-weight: 900;
}

.success-card {
  background: linear-gradient(135deg, #ffffff, var(--green-bg));
  border-color: #c7eed8;
}

.success-card .metric-icon {
  color: var(--green);
  border: 2px solid var(--green);
}

.warning-card {
  background: linear-gradient(135deg, #ffffff, var(--amber-bg));
  border-color: #f9db9a;
}

.warning-card .metric-icon {
  color: var(--amber);
  border: 2px solid var(--amber);
}

.error-card {
  background: linear-gradient(135deg, #ffffff, var(--red-bg));
  border-color: #f6c4c0;
}

.error-card .metric-icon {
  color: var(--red);
  border: 2px solid var(--red);
}

.info-card {
  background: linear-gradient(135deg, #ffffff, var(--blue-bg));
  border-color: #c7ddff;
}

.info-card .metric-icon {
  color: var(--blue);
  font-size: 21px;
}

.progress {
  position: absolute;
  left: 68px;
  right: 28px;
  bottom: 26px;
  height: 7px;
  border-radius: 999px;
  background: rgba(18, 183, 106, 0.16);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.split-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 14px;
  margin-bottom: 18px;
}

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

.module-header p {
  margin-bottom: 0;
  color: var(--muted);
}

.module-actions,
.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filters-row {
  align-items: center;
  margin-bottom: 14px;
}

.filters-row input {
  max-width: 360px;
}

.filters-row select {
  min-height: 38px;
  border: 1px solid #d0d5dd;
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
}

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

.section-heading,
.heading-inline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading {
  margin-bottom: 14px;
}

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

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--navy);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

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

.primary-button:disabled,
.secondary-button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: .55;
  filter: grayscale(0.18);
}

.muted-action {
  color: var(--muted);
  cursor: not-allowed;
  opacity: .6;
}

.plan-overview,
.plan-usage-card,
.plan-settings-box {
  min-width: 0;
  border: 1px solid #c7ddff;
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff, var(--blue-bg));
}

.plan-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 320px) auto;
  gap: 16px;
  align-items: center;
  margin: -8px 0 22px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.plan-overview h2,
.plan-usage-card strong,
.plan-settings-box strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--navy);
  font-size: 18px;
  line-height: 1.2;
}

.plan-overview p,
.plan-usage-card p,
.plan-settings-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.plan-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid #b2ccff;
  border-radius: 999px;
  color: var(--blue);
  background: #ffffff;
  font-size: 12px;
  font-weight: 850;
}

.plan-meter {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbeafe;
}

.plan-meter span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), #12b76a);
}

.plan-usage-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 260px) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
  padding: 15px 18px;
}

.plan-settings-box {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.role-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}

.role-cards article {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.role-cards strong {
  display: block;
  margin-bottom: 6px;
  color: var(--navy);
}

.role-cards p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.primary-button.block-button,
.block-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  margin-top: 16px;
  padding: 0 16px;
}

.inline-action {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inline-action button,
.bulk-bar button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.bulk-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
}

.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

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

.pagination-actions strong {
  color: var(--text);
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  background: var(--surface);
}

.matches-table {
  min-width: 980px;
}

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

th {
  color: var(--muted);
  background: #fcfcfd;
  font-size: 11px;
  font-weight: 850;
}

td {
  color: #1d2939;
  font-size: 13px;
}

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

.row-menu {
  width: 36px;
  color: var(--navy);
  font-size: 20px;
}

.dot {
  width: 7px;
  height: 7px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 50%;
}

.dot.success {
  background: var(--green);
}

.dot.warning {
  background: var(--amber);
}

.dot.error {
  background: var(--red);
}

.pdf-link,
.strong-link {
  white-space: nowrap;
  color: var(--navy);
}

.historical-table-wrap table {
  min-width: 860px;
}

.history-row.is-running {
  background: linear-gradient(90deg, rgba(21, 94, 239, 0.05), rgba(255, 255, 255, 0));
}

.history-id-link {
  display: inline-flex;
  color: var(--navy);
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.history-row td small,
.history-progress-cell small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.history-progress-cell {
  min-width: 190px;
}

.mini-progress {
  position: relative;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e7ec;
}

.mini-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.mini-progress.indeterminate span {
  width: 42% !important;
  background: linear-gradient(90deg, var(--blue), #53b1fd, var(--blue));
  animation: mini-progress-sweep 1.15s linear infinite;
}

@keyframes mini-progress-sweep {
  from {
    transform: translateX(-110%);
  }
  to {
    transform: translateX(245%);
  }
}

.table-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  white-space: nowrap;
  font-size: 12px;
  font-weight: 900;
}

.table-action.primary {
  border-color: var(--navy);
  background: var(--navy);
  color: #ffffff;
}

.process-note {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  background: var(--blue-bg);
  color: var(--navy);
  font-weight: 800;
}

.process-note.is-running {
  border-color: #fedf89;
  background: var(--amber-bg);
  color: #93370d;
}

.excerpt {
  display: block;
  max-width: 480px;
}

.quality-badge {
  min-width: 88px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.quality-badge.reliable {
  color: #067647;
  background: #ecfdf3;
  border-color: #75e0a7;
}

.quality-badge.review {
  color: #b54708;
  background: #fffaeb;
  border-color: #fdb022;
}

.match-reading-panel {
  display: grid;
  gap: 16px;
}

.match-reading-list {
  display: grid;
  gap: 14px;
}

.match-reading-card {
  min-width: 0;
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.match-reading-meta {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 16px;
  align-items: start;
}

.match-reading-meta strong {
  color: var(--navy);
  font-size: 15px;
}

.match-reading-meta span {
  grid-column: 1;
  color: var(--muted);
  font-weight: 750;
}

.match-reading-meta a {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
}

.match-ai-note,
.legal-excerpt-full {
  display: grid;
  gap: 7px;
}

.match-ai-note {
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: var(--blue-bg);
}

.match-ai-note span,
.legal-excerpt-full span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.match-ai-note p,
.legal-excerpt-full p {
  margin: 0;
  color: var(--text);
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.legal-excerpt-full {
  padding: 14px;
  border-left: 3px solid var(--blue);
  background: #fcfcfd;
}

.quality-note {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #fedf89;
  border-radius: 7px;
  background: var(--amber-bg);
  color: #93370d;
  font-weight: 800;
  line-height: 1.45;
}

.settings-feedback {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #abefc6;
  border-radius: 7px;
  background: var(--green-bg);
  color: #067647;
  font-weight: 800;
}

.settings-feedback.error {
  border-color: #fecdca;
  background: var(--red-bg);
  color: #b42318;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.range-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 7px;
  padding: 10px 11px;
  color: var(--text);
  background: #ffffff;
  outline: 0;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21, 94, 239, 0.12);
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.mini-metrics span {
  display: grid;
  gap: 3px;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #fcfcfd;
}

.mini-metrics strong {
  color: var(--text);
  font-size: 20px;
}

.recipient-list {
  display: grid;
  gap: 10px;
}

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

.recipient-list div:last-child {
  border-bottom: 0;
}

.recipient-list strong {
  color: var(--muted);
  font-size: 12px;
}

.output {
  white-space: pre-wrap;
  max-height: 320px;
  overflow: auto;
  margin: 0 0 18px;
  padding: 14px;
  border-radius: 7px;
  background: #101828;
  color: #e4e7ec;
  font-size: 12px;
}

.execution-panel {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: var(--blue-bg);
}

.execution-panel p {
  color: var(--muted);
}

.execution-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.execution-steps span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.execution-steps span.active {
  color: #067647;
  border-color: #abefc6;
  background: var(--green-bg);
}

.publication-layout {
  grid-template-columns: minmax(0, 1fr) 320px;
}

.historical-layout {
  grid-template-columns: minmax(0, 1fr) 340px;
}

.compact-status {
  margin-bottom: 18px;
}

.history-open-button {
  min-height: 48px;
  white-space: nowrap;
}

.history-modal .modal-card {
  width: min(1120px, calc(100vw - 28px));
}

.history-card {
  max-height: calc(100vh - 28px);
  overflow: auto;
}

.history-card > .section-heading {
  align-items: flex-start;
}

.history-card > .section-heading p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.history-block,
.history-progress {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.history-block h3,
.history-progress h3 {
  margin: 0 0 14px;
  color: var(--navy);
  font-size: 14px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

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

.quick-range-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.quick-range-buttons button,
.segmented button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--navy);
  font-weight: 800;
}

.estimate-box {
  margin: 12px 0 0;
  padding: 11px;
  color: #175cd3;
  background: var(--blue-bg);
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  font-size: 12px;
}

.radio-stack,
.check-stack {
  display: grid;
  gap: 10px;
}

.radio-stack label,
.check-stack label {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
}

.radio-stack input,
.check-stack input,
.case-picker input[type="checkbox"] {
  width: auto;
}

.case-picker {
  margin-top: 12px;
}

.case-selection-list {
  max-height: 220px;
  margin-top: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.case-option {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.case-option:last-child {
  border-bottom: 0;
}

.case-option:hover,
.case-option.selected {
  background: #eff4ff;
}

.case-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.case-check {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: transparent;
  border: 1px solid #98a2b3;
  border-radius: 6px;
  background: #ffffff;
  font-size: 13px;
  font-weight: 900;
}

.case-option.selected .case-check {
  color: #ffffff;
  background: var(--blue);
  border-color: var(--blue);
}

.case-option-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.case-option-main strong {
  color: var(--text);
  font-size: 13px;
}

.case-option-main small {
  color: var(--muted);
  font-size: 11px;
}

.case-expediente {
  color: var(--navy);
  font-weight: 900;
}

.mini-table {
  max-height: 180px;
  margin-top: 10px;
  overflow: auto;
}

.manual-history-fields {
  margin-top: 12px;
}

.history-progress {
  grid-column: span 3;
  background: var(--blue-bg);
  border-color: #bfdbfe;
}

.history-progress .section-heading {
  margin-bottom: 12px;
}

.progress.wide {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  width: 100%;
  height: 8px;
  margin-bottom: 12px;
  background: #dbeafe;
  border-radius: 999px;
}

.progress.wide span {
  display: block;
  height: 100%;
  background: var(--blue);
  border-radius: inherit;
}

.history-form .output,
.history-form .modal-actions {
  grid-column: span 3;
}

.bar-chart {
  min-height: 190px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fcfcfd;
}

.bar-chart span {
  width: 16px;
  min-height: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: var(--blue);
  border-radius: 4px 4px 0 0;
}

.bar-chart small {
  transform: translateY(-18px);
  color: var(--muted);
  font-size: 10px;
}

.quality-legend {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quality-legend .dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border-radius: 999px;
}

.quality-legend .dot.reliable {
  background: var(--green);
}

.quality-legend .dot.review {
  background: var(--amber);
}

.quality-date-chart {
  height: 190px;
  min-height: 190px;
  align-items: flex-end;
  gap: 7px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
}

.quality-date-chart .quality-bar {
  width: 16px;
  min-width: 16px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: visible;
  background: transparent;
  border-radius: 4px 4px 0 0;
}

.quality-date-chart .quality-bar i {
  width: 100%;
  display: block;
}

.quality-date-chart .review-segment {
  background: var(--amber);
  border-radius: 4px 4px 0 0;
}

.quality-date-chart .reliable-segment {
  background: var(--green);
  border-radius: 0 0 2px 2px;
}

.quality-date-chart .quality-bar small {
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.sparkline {
  width: 92px;
  height: 34px;
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
}

.sparkline i {
  width: 4px;
  display: block;
  background: var(--amber);
  border-radius: 999px 999px 0 0;
}

.mobile-activity {
  display: none;
  color: var(--muted);
  font-size: 11px;
}

.segmented {
  display: inline-flex;
  gap: 6px;
}

.segmented button.active {
  color: var(--blue);
  border-color: #bfdbfe;
  background: #eff4ff;
}

.background-job-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 80;
  width: min(430px, calc(100vw - 32px));
  padding: 16px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 20px 45px rgba(16, 24, 40, 0.18);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.background-job-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.background-job-toast.done {
  border-color: #abefc6;
}

.job-toast-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.job-toast-header strong {
  color: var(--navy);
}

.job-toast-header span {
  color: #175cd3;
  font-size: 12px;
  font-weight: 900;
}

.background-job-toast.done .job-toast-header span {
  color: #067647;
}

.background-job-toast p {
  margin: 0 0 12px;
  color: var(--muted);
}

.background-job-toast small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
}

.job-progress {
  height: 8px;
  overflow: hidden;
  background: #dbeafe;
  border-radius: 999px;
}

.job-progress i {
  display: block;
  height: 100%;
  background: var(--blue);
  border-radius: inherit;
  transition: width 380ms ease;
}

.background-job-toast.done .job-progress i {
  background: var(--green);
}

.case-detail-header,
.search-detail-header {
  margin-bottom: 18px;
}

.breadcrumbs {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumbs a,
.breadcrumbs strong {
  color: var(--navy);
}

.case-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.case-title-row h1 {
  font-size: 31px;
  margin-bottom: 8px;
}

.case-title-row p {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 17px;
}

.case-kpi-grid,
.history-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.case-kpi-grid article,
.history-kpi-grid article {
  min-height: 108px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.case-kpi-grid span,
.history-kpi-grid span {
  display: block;
  color: var(--muted);
  font-weight: 800;
}

.case-kpi-grid strong,
.history-kpi-grid strong {
  display: block;
  margin-top: 18px;
  color: var(--navy);
  font-size: 25px;
}

.history-kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.history-kpi-grid article {
  min-height: 104px;
  padding: 16px;
  overflow: hidden;
}

.history-kpi-grid article:first-child {
  grid-column: span 2;
}

.history-kpi-grid article:first-child strong {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  font-size: 22px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.history-kpi-grid article:first-child small {
  margin: 0;
  text-align: center;
}

.history-kpi-grid small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.case-tabs {
  display: flex;
  gap: 28px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.case-tabs a {
  padding: 0 0 14px;
  color: #475467;
  font-weight: 800;
}

.case-tabs a.active {
  color: var(--blue);
  border-bottom: 2px solid var(--blue);
}

.case-detail-layout,
.history-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 24px;
  align-items: start;
  min-width: 0;
}

.case-main,
.history-detail-main {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.history-detail-side {
  min-width: 0;
  display: grid;
  gap: 14px;
  align-content: start;
}

.history-priority-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.history-priority-grid > .panel {
  min-width: 0;
}

.compact-chart {
  min-height: 132px;
  max-height: 180px;
  overflow-x: auto;
}

.priority-timeline {
  margin-top: -4px;
}

.related-searches-row {
  grid-template-columns: minmax(0, 1fr);
}

.detail-tabs {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 0 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.detail-tabs button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: #ffffff;
  font-weight: 850;
  white-space: nowrap;
}

.detail-tabs button.active {
  color: var(--blue);
  border-color: #bfdbfe;
  background: var(--blue-bg);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.split-grid.tab-panel.active {
  display: grid;
}

.tab-stack {
  display: grid;
  gap: 18px;
}

.search-progress-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  font-weight: 800;
}

.search-steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
}

.search-steps::before {
  display: none;
}

.search-steps span {
  position: relative;
  z-index: 1;
  min-height: 46px;
  display: grid;
  align-content: center;
  gap: 4px;
  padding: 8px 10px 8px 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  line-height: 1.15;
  white-space: normal;
}

.search-steps span::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 12px;
  height: 12px;
  border: 2px solid #98a2b3;
  border-radius: 50%;
  background: #ffffff;
  transform: translateY(-50%);
}

.search-steps span::after {
  display: none;
}

.search-steps span.active {
  color: var(--navy);
  border-color: #abefc6;
  background: var(--green-bg);
}

.search-steps span.active::before {
  border-color: var(--green);
  background: var(--green);
  box-shadow: inset 0 0 0 3px #ffffff;
}

.execution-timeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  padding: 8px 0 4px;
}

.execution-timeline article {
  position: relative;
  min-height: 98px;
  display: grid;
  align-content: start;
  gap: 6px;
  padding-top: 24px;
}

.execution-timeline article::before {
  content: "";
  position: absolute;
  left: 10px;
  right: -22px;
  top: 9px;
  height: 1px;
  background: #b8c6d9;
}

.execution-timeline article:last-child::before {
  right: auto;
  width: 0;
}

.execution-timeline article > span {
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  border: 4px solid #ffffff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--line);
}

.execution-timeline article.green > span { background: var(--green); }
.execution-timeline article.blue > span { background: var(--blue); }
.execution-timeline article.amber > span { background: var(--amber); }
.execution-timeline article.gray > span { background: #98a2b3; }
.execution-timeline article.red > span { background: var(--red); }

.execution-timeline time {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.execution-timeline strong {
  color: var(--navy);
  font-size: 13px;
}

.execution-timeline small {
  color: var(--muted);
  line-height: 1.35;
}

.case-chart {
  min-height: 230px;
}

.case-mini-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 18px;
  border-top: 1px solid var(--line);
}

.case-mini-kpis span {
  display: grid;
  gap: 6px;
  padding: 18px;
  color: var(--muted);
  border-right: 1px solid var(--line);
  font-size: 12px;
}

.case-mini-kpis span:last-child {
  border-right: 0;
}

.case-mini-kpis strong {
  color: var(--navy);
  font-size: 18px;
}

.case-timeline {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 42px);
  overflow: auto;
}

.timeline-list {
  position: relative;
  display: grid;
  gap: 20px;
  padding: 10px 0 18px;
}

.timeline-list::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 18px;
  bottom: 28px;
  width: 2px;
  background: #d0d5dd;
}

.timeline-list article {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.timeline-list article > span {
  position: relative;
  z-index: 1;
  width: 36px;
  height: 36px;
  border: 4px solid #ffffff;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 1px var(--line);
}

.timeline-list article.green > span { background: var(--green); }
.timeline-list article.blue > span { background: var(--blue); }
.timeline-list article.amber > span { background: var(--amber); }
.timeline-list article.gray > span { background: #98a2b3; }
.timeline-list article.red > span { background: var(--red); }

.timeline-list time {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.timeline-list strong {
  display: block;
  margin-top: 3px;
  color: var(--navy);
}

.timeline-list p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.timeline-list button {
  min-height: 31px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--navy);
  background: #ffffff;
  font-weight: 800;
}

.detail-panel {
  align-self: start;
}

.detail-list {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 12px;
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-list dd {
  margin: 0;
}

.settings-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 300px;
  gap: 14px;
}

.settings-nav {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.settings-nav button {
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  font-weight: 850;
}

.settings-nav button.active,
.settings-nav button:hover {
  color: var(--navy);
  background: var(--blue-bg);
}

.settings-content {
  min-width: 0;
}

.settings-form {
  display: grid;
  gap: 14px;
  max-width: 680px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 29, 60, 0.42);
}

.modal.open {
  display: flex;
}

.modal-card {
  width: min(440px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  padding: 18px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.2);
}

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

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.switch-row input {
  width: 42px;
  height: 22px;
  accent-color: var(--blue);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 6px;
}

.primary-button {
  min-height: 38px;
  padding: 0 18px;
}

.bottom-nav {
  display: none;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 18% 18%, rgba(21, 94, 239, 0.12), transparent 28%),
    linear-gradient(135deg, var(--navy-dark), var(--navy) 45%, #f5f7fa 45%);
}

.login-shell {
  width: min(980px, 100%);
  display: grid;
  grid-template-columns: 1fr 430px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 80px rgba(3, 29, 60, 0.28);
}

.login-brand {
  min-height: 520px;
  padding: 42px;
  color: #ffffff;
  background: linear-gradient(180deg, var(--navy-dark), var(--navy));
}

.login-logo {
  padding: 0;
  margin-bottom: 86px;
}

.login-brand h1 {
  max-width: 390px;
  margin-bottom: 16px;
  font-size: 34px;
}

.login-brand p {
  max-width: 420px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 16px;
  line-height: 1.6;
}

.login-card {
  display: grid;
  align-content: center;
  gap: 22px;
  padding: 42px;
}

.login-card h2 {
  margin-bottom: 8px;
  font-size: 24px;
}

.login-card p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-submit {
  min-height: 44px;
}

.login-error {
  padding: 11px 12px;
  border: 1px solid #fecdca;
  border-radius: 7px;
  color: #b42318;
  background: var(--red-bg);
  font-weight: 700;
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .content {
    padding: 24px;
  }

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

  .dashboard-header {
    display: grid;
  }

  .header-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 860px) {
  body {
    padding-bottom: 76px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    display: none;
  }

  .content {
    padding: 16px;
  }

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

  .dashboard-header {
    gap: 14px;
  }

  .dashboard-header h1 {
    font-size: 22px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .run-now {
    grid-column: 1 / -1;
  }

  .run-now button {
    width: 100%;
    min-height: 48px;
    display: flex;
    justify-content: center;
    text-align: center;
  }

  .run-now small,
  .desktop-only {
    display: none;
  }

  .status-grid,
  .split-grid,
  .range-form,
  .mini-metrics,
  .plan-overview,
  .plan-usage-card {
    grid-template-columns: 1fr 1fr;
  }

  .plan-overview > div:first-child,
  .plan-usage-card > div:first-child {
    grid-column: 1 / -1;
  }

  .split-grid {
    display: grid;
  }

  .panel {
    padding: 14px;
  }

  .metric-card {
    min-height: 112px;
    grid-template-columns: 26px 1fr;
    gap: 10px;
    padding: 14px;
  }

  .metric-card h2 {
    font-size: 11px;
  }

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

  .metric-card a,
  .progress {
    display: none;
  }

  .metric-icon {
    width: 20px;
    height: 20px;
    font-size: 12px;
  }

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

  .lower-grid,
  .range-form {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 15;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(48px, 1fr));
    border-top: 1px solid var(--line);
    background: #ffffff;
    box-shadow: 0 -10px 30px rgba(16, 24, 40, 0.08);
  }

  .module-header,
  .publication-layout,
  .historical-layout,
  .settings-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .history-modal .modal-card {
    width: 100vw;
    min-height: 100vh;
    border-radius: 0;
  }

  .history-form {
    grid-template-columns: 1fr;
  }

  .case-title-row,
  .case-detail-layout,
  .history-detail-layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .case-kpi-grid,
  .history-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-priority-grid {
    grid-template-columns: 1fr;
  }

  .search-steps,
  .execution-timeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-steps::before,
  .execution-timeline article::before {
    display: none;
  }

  .case-tabs {
    overflow-x: auto;
    white-space: nowrap;
  }

  .case-timeline {
    position: static;
    max-height: none;
  }

  .history-progress,
  .history-form .output,
  .history-form .modal-actions {
    grid-column: auto;
  }

  .module-actions,
  .filters-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .filters-row input {
    max-width: none;
    grid-column: 1 / -1;
  }

  .bottom-nav a {
    display: grid;
    justify-items: center;
    gap: 4px;
    padding: 9px 4px 8px;
    color: var(--muted);
    font-size: 18px;
  }

  .bottom-nav span {
    font-size: 10px;
  }

  .bottom-nav a.active {
    color: var(--navy);
  }

  .login-body {
    display: block;
    padding: 0;
    background: var(--bg);
  }

  .login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
  }

  .login-brand {
    min-height: auto;
    padding: 28px 24px;
  }

  .login-logo {
    margin-bottom: 34px;
  }

  .login-card {
    align-content: start;
    padding: 28px 24px;
  }
}

@media (max-width: 520px) {
  .status-grid {
    gap: 10px;
  }

  .metric-card {
    min-height: 104px;
  }

  .header-actions,
  .status-grid,
  .mini-metrics,
  .plan-overview,
  .plan-usage-card {
    grid-template-columns: 1fr 1fr;
  }

  .last-check {
    min-width: 0;
  }

  .section-heading {
    display: grid;
  }

  .form-grid.two,
  .quick-range-buttons,
  .module-actions,
  .filters-row {
    grid-template-columns: 1fr;
  }

  .sparkline {
    display: none;
  }

  .mobile-activity {
    display: inline;
  }

  .case-kpi-grid,
  .history-kpi-grid,
  .case-mini-kpis {
    grid-template-columns: 1fr;
  }

  .case-mini-kpis span {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .case-mini-kpis span:last-child {
    border-bottom: 0;
  }

  .timeline-list article {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .timeline-list button {
    grid-column: 2;
    justify-self: start;
  }
}
