:root {
  --cp-bg: #f3f4f6;
  --cp-surface: #ffffff;
  --cp-surface-muted: #f8fafc;
  --cp-border: #d9e2ec;
  --cp-border-strong: #cbd5e1;
  --cp-text: #1f2937;
  --cp-text-muted: #4b5563;
  --cp-text-soft: #6b7280;
  --cp-accent: #374151;
  --cp-accent-hover: #2f3947;
  --cp-accent-active: #1f2937;
  --cp-radius-lg: 16px;
  --cp-radius-md: 14px;
  --cp-radius-sm: 10px;
  --cp-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  --cp-shadow-soft: 0 1px 2px rgba(15, 23, 42, 0.04);
  --cp-topbar-height: 73px;
}

.landing-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 18% 14%, rgba(225, 247, 242, 0.72), transparent 32%),
    radial-gradient(circle at 88% 18%, rgba(228, 241, 255, 0.66), transparent 34%),
    linear-gradient(135deg, #ffffff 0%, #f8fbf8 42%, #f2f9fb 100%);
  color: #111827;
}

.landing-shell {
  position: relative;
  overflow: hidden;
}

.landing-shell::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(36, 80, 68, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.026) 1px, transparent 1px);
  background-size: 48px 48px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 78%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 78%);
  pointer-events: none;
}

.landing-shell::after {
  content: "";
  position: fixed;
  top: -18vh;
  left: -16vw;
  width: 54vw;
  height: 54vw;
  min-width: 520px;
  min-height: 520px;
  z-index: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.82) 0%, rgba(222, 247, 244, 0.32) 36%, transparent 68%);
  opacity: 0.78;
  transform: translate3d(0, 0, 0);
  animation: landing-light-drift 26s ease-in-out infinite alternate;
  pointer-events: none;
  will-change: transform;
}

.landing-section {
  z-index: 1;
}

@keyframes landing-light-drift {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(58vw, 14vh, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .landing-shell::after {
    animation: none;
    transform: translate3d(24vw, 6vh, 0);
  }
}

.landing-section {
  position: relative;
  padding: 96px 24px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
}

.landing-hero {
  min-height: 100vh;
  padding-top: 18px;
}

.landing-frame {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 24px;
  margin-bottom: 64px;
}

.landing-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #17201b;
  font-weight: 850;
  text-decoration: none;
}

.landing-brand-symbol {
  width: 19px;
  height: auto;
  display: block;
  transform: translateY(1px);
}

.landing-brand-name {
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0;
}

.landing-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 0.78fr);
  gap: 68px;
  align-items: center;
}

.landing-hero-copy {
  max-width: 720px;
}

.landing-kicker {
  margin: 0 0 16px;
  color: #17654f;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.landing-hero-copy h1,
.landing-section-heading h2 {
  margin: 0;
  color: #131915;
  font-size: clamp(30px, 4.1vw, 50px);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.05;
}

.landing-hero-copy h1 {
  max-width: 16ch;
}

.landing-lead {
  max-width: 38rem;
  margin: 24px 0 0;
  color: #415149;
  font-size: clamp(17px, 1.6vw, 20px);
  line-height: 1.55;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.landing-button {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid rgba(22, 92, 82, 0.88);
  border-radius: 8px;
  background: linear-gradient(135deg, #176b60 0%, #144f47 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 750;
  letter-spacing: 0;
  text-decoration: none;
  box-sizing: border-box;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 10px 22px rgba(20, 79, 71, 0.16);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.landing-button::after {
  content: "";
  position: absolute;
  inset: -1px auto -1px -52%;
  z-index: -1;
  width: 42%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: skewX(-18deg);
  transition: left 0.55s ease;
}

.landing-button:hover {
  background: linear-gradient(135deg, #1a7669 0%, #15584f 100%);
  border-color: rgba(28, 116, 103, 0.95);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.22) inset, 0 12px 26px rgba(20, 79, 71, 0.2);
}

.landing-button:hover::after {
  left: 112%;
}

.landing-button:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.28);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .landing-button,
  .landing-button::after {
    transition: none;
  }

  .landing-button::after {
    display: none;
  }
}

.landing-product-panel {
  border: 1px solid rgba(23, 32, 27, 0.08);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.07);
  overflow: hidden;
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.landing-product-panel:hover {
  border-color: rgba(36, 80, 68, 0.14);
  box-shadow: 0 18px 42px rgba(17, 24, 39, 0.09);
  transform: translateY(-1px);
}

.landing-panel-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(23, 32, 27, 0.1);
  color: #657169;
  font-size: 13px;
  font-weight: 800;
}

.landing-panel-top strong {
  padding: 5px 9px;
  border-radius: 999px;
  background: #e3f5d1;
  color: #245d32;
  font-size: 12px;
}

.landing-product-preview {
  --landing-preview-cycle: 18s;
}

.landing-product-preview .landing-panel-top,
.landing-product-preview .landing-score,
.landing-product-preview .landing-table,
.landing-product-preview .landing-panel-note {
  animation: landing-document-appear var(--landing-preview-cycle) ease-in-out infinite;
}

.landing-panel-top .landing-preview-state {
  display: grid;
  min-width: 62px;
  min-height: 26px;
  padding: 0 9px;
  place-items: center;
  box-sizing: border-box;
  animation: landing-state-color var(--landing-preview-cycle) ease-in-out infinite;
}

.landing-preview-state span,
.landing-score-value span,
.landing-preview-status strong {
  grid-area: 1 / 1;
}

.landing-preview-state-analysis,
.landing-preview-state-ready {
  animation-duration: var(--landing-preview-cycle);
  animation-iteration-count: infinite;
}

.landing-preview-state-analysis {
  animation-name: landing-analysis-label;
}

.landing-preview-state-ready {
  animation-name: landing-ready-label;
}

.landing-analysis-progress {
  height: 2px;
  background: rgba(23, 101, 79, 0.08);
  overflow: hidden;
}

.landing-analysis-progress span {
  display: block;
  width: 100%;
  height: 100%;
  background: #2a8972;
  transform: scaleX(0);
  transform-origin: left center;
  animation: landing-analysis-progress var(--landing-preview-cycle) ease-in-out infinite;
  will-change: transform;
}

.landing-score {
  padding: 22px 20px;
}

.landing-score p,
.landing-panel-note p {
  margin: 0;
  color: #6a776f;
  font-size: 13px;
  line-height: 1.45;
}

.landing-score strong {
  display: block;
  margin-top: 7px;
  color: #17201b;
  font-size: 22px;
  line-height: 1.1;
}

.landing-score-value {
  display: grid !important;
  min-height: 24px;
}

.landing-score > div {
  animation: landing-summary-update var(--landing-preview-cycle) ease-in-out infinite;
}

.landing-score-pending,
.landing-score-ready {
  animation-duration: var(--landing-preview-cycle);
  animation-iteration-count: infinite;
}

.landing-score-pending {
  animation-name: landing-score-pending;
}

.landing-score-ready {
  animation-name: landing-score-ready;
}

.landing-table {
  display: grid;
  gap: 1px;
  background: rgba(23, 32, 27, 0.08);
}

.landing-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 88px 108px;
  gap: 12px;
  align-items: center;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.92);
  color: #26332d;
  font-size: 13px;
}

.landing-preview-row {
  animation-duration: var(--landing-preview-cycle);
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

.landing-preview-row-ok {
  animation-name: landing-row-ok;
}

.landing-preview-row-risk {
  animation-name: landing-row-risk;
}

.landing-preview-row-new {
  animation-name: landing-row-new;
}

.landing-table-head {
  background: #f2f4ee;
  color: #718078;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.landing-table strong,
.landing-preview-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: start;
  width: 82px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  box-sizing: border-box;
  text-align: center;
}

.landing-preview-status {
  display: grid;
  padding: 0;
}

.landing-preview-status strong {
  width: 82px;
}

.landing-preview-status-pending {
  background: #eef2f3;
  color: #748079;
}

.landing-preview-status-result,
.landing-preview-status-pending {
  animation-duration: var(--landing-preview-cycle);
  animation-iteration-count: infinite;
}

.landing-preview-status-result {
  opacity: 0;
}

.landing-preview-row-ok .landing-preview-status-pending {
  animation-name: landing-pending-ok;
}

.landing-preview-row-ok .landing-preview-status-result {
  animation-name: landing-result-ok;
}

.landing-preview-row-risk .landing-preview-status-pending {
  animation-name: landing-pending-risk;
}

.landing-preview-row-risk .landing-preview-status-result {
  animation-name: landing-result-risk;
}

.landing-preview-row-new .landing-preview-status-pending {
  animation-name: landing-pending-new;
}

.landing-preview-row-new .landing-preview-status-result {
  animation-name: landing-result-new;
}

.status-ok {
  background: #e3f5d1;
  color: #2d6838;
}

.status-watch {
  background: #fff1c2;
  color: #8a5c00;
}

.status-risk {
  background: #ffe0dc;
  color: #9c372e;
}

.status-new {
  background: #e4effb;
  color: #2f628f;
}

.landing-panel-note {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 16px;
  padding: 18px 20px 20px;
}

.landing-panel-note span {
  color: #17654f;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

@keyframes landing-document-appear {
  0%, 3% { opacity: 0; }
  8%, 94% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes landing-analysis-progress {
  0%, 9% { opacity: 0; transform: scaleX(0); }
  12% { opacity: 1; transform: scaleX(0); }
  62% { opacity: 1; transform: scaleX(1); }
  66%, 100% { opacity: 0; transform: scaleX(1); }
}

@keyframes landing-analysis-label {
  0%, 8%, 66%, 100% { opacity: 0; }
  12%, 61% { opacity: 1; }
}

@keyframes landing-ready-label {
  0%, 61%, 100% { opacity: 0; }
  66%, 94% { opacity: 1; }
}

@keyframes landing-state-color {
  0%, 61%, 100% { background: #e7f3ef; color: #17654f; }
  66%, 94% { background: #e3f5d1; color: #245d32; }
}

@keyframes landing-row-ok {
  0%, 16%, 29%, 100% { background: rgba(255, 255, 255, 0.92); }
  20%, 25% { background: #f0f8f5; }
}

@keyframes landing-row-risk {
  0%, 31%, 44%, 100% { background: rgba(255, 255, 255, 0.92); }
  35%, 40% { background: #fff4f2; }
}

@keyframes landing-row-new {
  0%, 46%, 59%, 100% { background: rgba(255, 255, 255, 0.92); }
  50%, 55% { background: #f1f6fb; }
}

@keyframes landing-pending-ok {
  0%, 23% { opacity: 1; }
  27%, 100% { opacity: 0; }
}

@keyframes landing-result-ok {
  0%, 23% { opacity: 0; }
  27%, 94% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes landing-pending-risk {
  0%, 38% { opacity: 1; }
  42%, 100% { opacity: 0; }
}

@keyframes landing-result-risk {
  0%, 38% { opacity: 0; }
  42%, 94% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes landing-pending-new {
  0%, 53% { opacity: 1; }
  57%, 100% { opacity: 0; }
}

@keyframes landing-result-new {
  0%, 53% { opacity: 0; }
  57%, 94% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes landing-score-pending {
  0%, 57% { opacity: 1; }
  62%, 100% { opacity: 0; }
}

@keyframes landing-score-ready {
  0%, 57% { opacity: 0; }
  62%, 94% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes landing-summary-update {
  0%, 59%, 78%, 100% { background: transparent; }
  65%, 73% { background: rgba(227, 245, 209, 0.38); }
}

@media (prefers-reduced-motion: reduce) {
  .landing-product-preview .landing-panel-top,
  .landing-product-preview .landing-score,
  .landing-product-preview .landing-table,
  .landing-product-preview .landing-panel-note,
  .landing-preview-state,
  .landing-preview-state span,
  .landing-analysis-progress span,
  .landing-score > div,
  .landing-score-value span,
  .landing-preview-row,
  .landing-preview-status strong {
    animation: none;
  }

  .landing-preview-state-analysis,
  .landing-score-pending,
  .landing-preview-status-pending {
    display: none;
  }

  .landing-preview-state-ready,
  .landing-score-ready,
  .landing-preview-status-result {
    opacity: 1;
  }

  .landing-analysis-progress span {
    opacity: 0;
  }
}

.landing-section-heading {
  display: grid;
  gap: 14px;
  max-width: 820px;
  margin-bottom: 34px;
}

.landing-section-heading h2,
.landing-result-panel h2 {
  font-size: clamp(34px, 4vw, 56px);
  line-height: 1.04;
}

.landing-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.landing-step {
  min-height: 255px;
  padding: 24px;
  border: 1px solid rgba(23, 32, 27, 0.08);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.055);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.landing-step:hover {
  border-color: rgba(36, 80, 68, 0.14);
  box-shadow: 0 16px 38px rgba(17, 24, 39, 0.075);
  transform: translateY(-1px);
}

.landing-step-index,
.landing-benefits article span {
  display: block;
  color: #17654f;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.landing-step h3,
.landing-benefits h3 {
  margin: 58px 0 0;
  color: #17201b;
  font-size: 23px;
  line-height: 1.12;
}

.landing-step p {
  max-width: 25ch;
  margin: 14px 0 0;
  color: #617169;
  font-size: 15px;
  line-height: 1.52;
}

.landing-control {
  background: #1f342d;
  color: #f7f6ef;
}

.landing-control .landing-kicker,
.landing-control .landing-section-heading h2,
.landing-control h3 {
  color: #f7f6ef;
}

.landing-control-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

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

.landing-benefits article {
  min-height: 210px;
  padding: 22px;
  border: 1px solid rgba(247, 246, 239, 0.11);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08);
  transition: border-color 0.22s ease, background-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.landing-benefits article:hover {
  border-color: rgba(247, 246, 239, 0.18);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.landing-benefits article span {
  color: #d0f06a;
}

.landing-benefits h3 {
  margin-top: 48px;
  font-size: 21px;
}

.landing-benefits p {
  margin: 12px 0 0;
  color: #c7d0ca;
  font-size: 14px;
  line-height: 1.55;
}

.landing-result {
  min-height: 74vh;
}

.landing-result-panel {
  padding: 58px;
  border: 1px solid rgba(23, 32, 27, 0.08);
  border-radius: 20px;
  background: #ffffff;
  box-shadow: 0 14px 38px rgba(17, 24, 39, 0.06);
  transition: border-color 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

.landing-result-panel:hover {
  border-color: rgba(36, 80, 68, 0.14);
  box-shadow: 0 18px 44px rgba(17, 24, 39, 0.08);
  transform: translateY(-1px);
}

.landing-result-panel p:not(.landing-kicker) {
  max-width: 620px;
  margin: 22px 0 0;
  color: #55645d;
  font-size: 18px;
  line-height: 1.55;
}

.landing-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}

.login-page {
  min-height: 100vh;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  box-sizing: border-box;
}

.login-card {
  width: min(100%, 440px);
  padding: 34px;
  border: 1px solid rgba(23, 32, 27, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 22px 60px rgba(17, 24, 39, 0.08);
  box-sizing: border-box;
}

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

.login-step h1 {
  margin: 0;
  color: #131915;
  font-size: clamp(30px, 5vw, 42px);
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.08;
}

.login-subtitle {
  margin: 12px 0 0;
  color: #415149;
  font-size: 17px;
  line-height: 1.5;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 28px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: #26332d;
  font-size: 14px;
  font-weight: 750;
}

.login-form input,
.login-form select {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(36, 80, 68, 0.2);
  border-radius: 8px;
  background: #ffffff;
  color: #17201b;
  font-size: 15px;
  box-sizing: border-box;
}

.login-form input:focus,
.login-form select:focus {
  outline: 3px solid rgba(36, 80, 68, 0.16);
  border-color: rgba(36, 80, 68, 0.52);
}

.login-label-note {
  color: #6b7b72;
  font-size: 12px;
  font-weight: 600;
}

.login-primary-button {
  width: 100%;
  margin-top: 4px;
}

.login-secondary-button {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: #415149;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.login-secondary-button:hover,
.login-secondary-button:focus,
.login-secondary-link:hover,
.login-secondary-link:focus {
  color: #17201b;
  text-decoration: underline;
}

.login-secondary-link {
  justify-self: center;
  color: #415149;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.login-dev-hint {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(36, 80, 68, 0.12);
  border-radius: 8px;
  background: rgba(36, 80, 68, 0.05);
  color: #415149;
  font-size: 13px;
  line-height: 1.4;
}

.login-error {
  margin: -4px 0 0;
  color: #9c372e;
  font-size: 13px;
  line-height: 1.4;
}

.login-status {
  margin: -4px 0 0;
  color: #2f684d;
  font-size: 13px;
  line-height: 1.4;
}

body {
  margin: 0;
  background: var(--cp-bg);
  color: var(--cp-text);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

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

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(243, 244, 246, 0.94);
  border-bottom: 1px solid var(--cp-border);
  backdrop-filter: blur(8px);
}

.app-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.app-topbar-brand strong {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.app-topbar-brand span {
  color: var(--cp-text-soft);
  font-size: 12px;
  white-space: nowrap;
}

.mobile-topbar {
  display: none;
}

.sidebar {
  position: fixed;
  top: var(--cp-topbar-height);
  left: 0;
  width: 252px;
  height: calc(100vh - var(--cp-topbar-height));
  padding: 28px 18px;
  background: #f7f9fb;
  border-right: 1px solid var(--cp-border);
  box-sizing: border-box;
  overflow-y: auto;
}

.sidebar-brand {
  margin-bottom: 28px;
}

.mode-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-sm);
  background: var(--cp-surface);
  box-sizing: border-box;
}

.app-topbar-mode-switch {
  width: auto;
  min-width: 320px;
  margin: 0;
  flex: 0 0 auto;
}

.mode-switch-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--cp-radius-sm);
  background: transparent;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.mode-switch-button:hover:not(:disabled) {
  background: #f3f4f6;
  color: #111827;
}

.mode-switch-button:active:not(:disabled) {
  background: #e5e7eb;
  color: #111827;
}

.mode-switch-button.is-active {
  background: #374151;
  color: #ffffff;
}

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

.sidebar-brand strong {
  font-size: 24px;
  letter-spacing: -0.02em;
}

.sidebar-brand span {
  margin-top: 6px;
  color: #6b7280;
  font-size: 12px;
}

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

.app-nav-link {
  width: 100%;
  padding: 12px 14px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #4b5563;
  text-align: left;
  font-size: 14px;
  font-weight: 600;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.app-nav-link:hover {
  background: #374151;
  color: #ffffff;
}

.app-nav-link:active {
  background: #1f2937;
  color: #ffffff;
}

.app-nav-link.is-active {
  background: #2f3b4a;
  color: #ffffff;
}

.app-nav-link.is-active:hover {
  background: #1f2937;
  color: #ffffff;
}

.container {
  max-width: 1240px;
  margin-left: 252px;
  padding: 32px 24px 56px;
  box-sizing: border-box;
}

.page-container {
  width: 100%;
  max-width: 1760px;
  margin: 0 auto;
  padding-left: 36px;
  padding-right: 36px;
  box-sizing: border-box;
}

body[data-ui-mode="user"] [data-admin-only] {
  display: none !important;
}

body[data-ui-mode="admin"] [data-user-only] {
  display: none !important;
}

body[data-ui-mode="admin"] .page-header[data-user-only],
body[data-ui-mode="admin"] #analytics-section[data-user-only],
body[data-ui-mode="admin"] #upload-section[data-user-only],
body[data-ui-mode="admin"] #check-section[data-user-only],
body[data-ui-mode="admin"] #history-section[data-user-only] {
  display: none !important;
  margin: 0 !important;
}

.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.page-header-copy,
.workflow-steps {
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-lg);
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow);
}

.page-header-copy {
  padding: 24px;
}

.page-header h1 {
  margin: 0 0 8px;
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.page-header p {
  margin: 0;
  color: #4b5563;
  font-size: 15px;
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.user-upload-hero {
  display: none;
}

.beta-notice {
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #f8fbff;
  color: #1e3a8a;
  font-size: 13px;
  line-height: 1.5;
}

.workflow-steps {
  display: grid;
  gap: 0;
  padding: 18px 20px;
}

.workflow-step {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0 14px 2px;
}

.workflow-step + .workflow-step {
  border-top: 1px solid #edf2f7;
}

.workflow-step-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  box-sizing: border-box;
}

.workflow-step strong,
.workflow-step span {
  display: block;
}

.workflow-step strong {
  margin-bottom: 3px;
  font-size: 14px;
  color: #0f172a;
}

.workflow-step span {
  color: #4b5563;
  font-size: 13px;
  line-height: 1.45;
}

.panel {
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-lg);
  padding: 24px;
  margin-bottom: 28px;
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow);
  box-sizing: border-box;
}

.panel-primary {
  border-color: var(--cp-border);
}

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

.dashboard-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 28px;
  position: relative;
  z-index: 1;
}

.sticky-stats-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 0 28px;
  padding: 12px 0 14px;
  background: var(--cp-bg);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
  box-sizing: border-box;
}

.dashboard-strip-caption {
  margin: 0 0 10px;
}

.kpi-card {
  padding: 16px 18px;
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-lg);
  box-shadow: var(--cp-shadow);
}

.kpi-card strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.1;
}

.panel h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.section-help {
  margin: 4px 0 0;
  color: var(--cp-text-muted);
  font-size: 13px;
  line-height: 1.45;
  max-width: 46ch;
}

.subpanel {
  margin: 8px 0 20px;
}

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

.section-head h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.section-caption {
  margin: 0;
  color: var(--cp-text-soft);
  font-size: 13px;
  line-height: 1.45;
  text-align: right;
}

.validation-status-help {
  margin-top: 6px;
  max-width: 860px;
}

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

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

.history-filter-search {
  grid-column: span 1;
}

.history-filter-field {
  min-width: 0;
}

.history-filter-field input,
.history-filter-field select {
  width: 100%;
  box-sizing: border-box;
}

.history-form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-form-actions button {
  min-width: 0;
}

.full-width {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--cp-text);
}

input[type="text"],
input[type="date"],
select {
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid var(--cp-border-strong);
  border-radius: var(--cp-radius-sm);
  font-size: 14px;
  font-weight: 400;
  background: var(--cp-surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-sizing: border-box;
}

input[type="text"]:focus,
input[type="date"]:focus,
select:focus,
button:focus,
.file-input-button:focus {
  outline: none;
  border-color: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.18);
}

button:focus-visible:not(:disabled),
.file-input-button:focus-visible,
.app-nav-link:focus-visible,
.table-sort-button:focus-visible,
.filter-button:focus-visible,
.failed-filter-button:focus-visible,
.documents-file-button:focus-visible,
.upload-row-link:focus-visible,
.document-actions-item:focus-visible,
.modal-close-button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.22);
}

.file-input {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

#upload-form .file-input,
#validate-form .file-input {
  align-items: center;
  justify-content: flex-start;
  padding: 16px;
  border: 1px dashed var(--cp-border-strong);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface-muted);
}

.import-stats {
  padding: 12px 14px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface-muted);
}

.import-stats span {
  color: #475569;
  font-size: 13px;
}

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

.file-input-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--cp-accent);
  border-radius: 8px;
  background: var(--cp-accent);
  color: #ffffff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.file-input-button:hover {
  background: #3f4b5c;
  border-color: #3f4b5c;
}

.file-input-button:active {
  background: #2f3947;
  border-color: #2f3947;
  color: #ffffff;
}

.file-input-button.is-disabled {
  background: #9ca3af;
  border-color: #9ca3af;
  color: #f9fafb;
  cursor: not-allowed;
  pointer-events: none;
}

.file-input-button.is-success {
  background: #166534;
  border-color: #166534;
}

.file-input-button.is-success:hover,
.file-input-button.is-success:active {
  background: #166534;
  border-color: #166534;
}

.file-input-button.is-error {
  background: #b91c1c;
  border-color: #b91c1c;
}

.file-input-button.is-error:hover,
.file-input-button.is-error:active {
  background: #b91c1c;
  border-color: #b91c1c;
}

.input-note {
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
}

.file-input-name {
  color: #6b7280;
  font-weight: 400;
}

button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--cp-accent);
  color: #ffffff;
  font-size: 15px;
  cursor: pointer;
  font-weight: 700;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

button:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  background: #3f4b5c;
}

button:active:not(:disabled) {
  background: #2f3947;
  color: #ffffff;
}

.secondary-button {
  background: #f3f4f6;
  color: #111827;
  border: 1px solid var(--cp-border);
}

.secondary-button:hover:not(:disabled) {
  background: #e5e7eb;
  color: #111827;
  border-color: #cbd5e1;
}

.secondary-button:active:not(:disabled) {
  background: #e5e7eb;
  color: #111827;
  border-color: #cbd5e1;
}

.danger-button {
  background: #b91c1c;
  color: #ffffff;
}

.danger-button:hover:not(:disabled) {
  background: #a61b1b;
}

.danger-button:active:not(:disabled) {
  background: #991b1b;
  color: #ffffff;
}

.upload-actions {
  display: none;
}

.compact-button {
  min-height: 38px;
  height: 38px;
  padding: 0 14px;
  font-size: 15px;
}

button:disabled {
  background: #9ca3af;
  color: #f9fafb;
  border-color: #9ca3af;
  cursor: not-allowed;
}

.result-box {
  min-height: 80px;
  padding: 14px 16px;
  background: var(--cp-surface-muted);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.import-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 14px;
  color: #4b5563;
}

.metadata-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 16px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface-muted);
}

.metadata-grid span {
  color: #6b7280;
}

.validation-version-actions {
  margin-bottom: 16px;
}

.duplicate-notice {
  margin: 0 0 14px;
  padding: 16px 18px;
  border: 1px solid #cbd5e1;
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fbff, #eef6ff);
  color: #1e293b;
  box-shadow: 0 10px 24px rgba(148, 163, 184, 0.14);
}

.validation-version-actions.is-duplicate .duplicate-notice {
  border-color: #bae6fd;
  background: linear-gradient(180deg, #f0f9ff, #e0f2fe);
}

.duplicate-notice-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
}

.duplicate-notice-text {
  margin: 0 0 10px;
  color: #334155;
  font-size: 14px;
  line-height: 1.5;
}

.duplicate-notice-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.duplicate-notice-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.28);
  color: #334155;
  font-size: 13px;
  line-height: 1.35;
}

.upload-documents-block {
  margin: 0 0 16px;
}

.uploaded-documents-block {
  margin-top: 16px;
}

.upload-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 0;
}

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

.summary-card-compact {
  padding: 10px 12px;
}

.summary-card-compact strong {
  font-size: 20px;
}

.documents-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.maintenance-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.maintenance-report {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.maintenance-report-header {
  display: grid;
  gap: 4px;
}

.maintenance-report-header strong {
  color: #111827;
}

.maintenance-report-header span {
  color: #4b5563;
  font-size: 13px;
  line-height: 1.5;
}

.maintenance-report-header-error strong,
.maintenance-report-header-error span {
  color: #991b1b;
}

.maintenance-report-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.maintenance-report-metrics div,
.maintenance-report-card {
  padding: 12px 14px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface);
}

.maintenance-report-metrics span,
.maintenance-report-card span,
.maintenance-report-card small {
  display: block;
  color: #6b7280;
}

.maintenance-report-metrics span,
.maintenance-report-card span {
  margin-bottom: 6px;
  font-size: 12px;
}

.maintenance-report-metrics strong,
.maintenance-report-card strong {
  color: #111827;
  font-size: 18px;
  line-height: 1.3;
}

.maintenance-report-card small {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
}

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

.documents-browser-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.6fr) repeat(5, minmax(140px, 1fr));
  gap: 10px 12px;
  margin: 0 0 14px;
  align-items: end;
}

.documents-browser-toolbar label {
  gap: 6px;
  font-size: 13px;
}

.documents-toolbar-search {
  min-width: 0;
}

.documents-toolbar-search input {
  width: 100%;
}

.documents-browser-table {
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow-soft);
}

.documents-table {
  table-layout: fixed;
}

.documents-table th:nth-child(2),
.documents-table td:nth-child(2) {
  width: 24%;
}

.documents-table th:last-child,
.documents-table td:last-child {
  width: 72px;
}

.table-sort-button {
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: #475569;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-transform: inherit;
  white-space: nowrap;
}

.table-sort-button:hover {
  color: #1f2937;
}

.table-sort-button:active {
  color: #334155;
}

.table-sort-button.is-active {
  color: #111827;
}

.table-sort-button[data-sort-direction="asc"]::after {
  content: " ↑";
}

.table-sort-button[data-sort-direction="desc"]::after {
  content: " ↓";
}

.documents-file-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #111827;
  font: inherit;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.documents-file-button:hover {
  color: #1d4ed8;
}

.documents-file-button:active {
  color: #1e40af;
}

.documents-file-cell {
  display: grid;
  gap: 8px;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 10px;
  border: 1px solid var(--cp-border);
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

.version-badge.is-current {
  border-color: #cbd5e1;
  background: #eef2f7;
  color: #1f2937;
}

.documents-row-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.documents-supplier-cell {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.35;
  max-height: calc(1.35em * 2);
  overflow-wrap: anywhere;
}

.document-actions-menu {
  display: inline-flex;
  justify-content: flex-end;
  width: 100%;
}

.document-actions-toggle {
  min-width: 36px;
  padding: 6px 8px;
  font-size: 18px;
  line-height: 1;
}

.document-actions-dropdown {
  z-index: 30;
  display: grid;
  min-width: 160px;
  padding: 6px;
  border: 1px solid var(--cp-border);
  border-radius: 12px;
  background: var(--cp-surface);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
}

.document-actions-dropdown.is-portal {
  gap: 4px;
  z-index: 1100;
}

.document-actions-item {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.document-actions-item:hover {
  background: #f3f4f6;
  color: #111827;
}

.document-actions-item:active {
  background: #e5e7eb;
  color: #111827;
}

.document-actions-item.is-danger {
  color: #b91c1c;
}

.document-actions-item.is-danger:hover {
  background: #fef2f2;
  color: #991b1b;
}

.document-actions-item.is-danger:active {
  background: #fee2e2;
  color: #991b1b;
}

.document-actions-portal[hidden] {
  display: none !important;
}

.documents-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: #4b5563;
  font-size: 13px;
}

.documents-pagination-actions {
  display: inline-flex;
  gap: 8px;
}

.documents-mobile-list {
  display: none;
  gap: 10px;
  margin-top: 12px;
}

.document-mobile-empty,
.document-mobile-card {
  border: 1px solid var(--cp-border);
  border-radius: 12px;
  background: var(--cp-surface);
  padding: 14px;
}

.document-mobile-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.document-mobile-card-head strong {
  font-size: 14px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.document-mobile-card-title {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.document-mobile-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin: 0 0 12px;
}

.document-mobile-meta div {
  min-width: 0;
}

.document-mobile-meta dt {
  margin: 0 0 4px;
  color: #6b7280;
  font-size: 12px;
}

.document-mobile-meta dd {
  margin: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.documents-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
}

.documents-filter-toggle input {
  margin: 0;
}

.upload-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.upload-row-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: #1d4ed8;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.upload-row-link:hover {
  text-decoration: underline;
}

.upload-multi-block {
  margin: 0 0 16px;
  padding: 16px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface-muted);
}

.upload-multi-head {
  margin-bottom: 12px;
}

.upload-multi-head h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.upload-multi-head p {
  margin: 0;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.5;
}

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

.upload-multi-stats div {
  padding: 12px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface);
}

.upload-review-panel {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}

.upload-review-form {
  margin-bottom: 0;
}

.line-analysis-meta {
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-debug {
  margin-top: 4px;
  font-size: 12px;
  color: #4b5563;
}

.history-debug summary {
  cursor: pointer;
  color: #1d4ed8;
}

.history-debug-list {
  margin-top: 4px;
  display: grid;
  gap: 4px;
}

.user-details-toolbar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 12px;
}

.section-toggle-button {
  align-self: center;
}

#category-section-content {
  display: grid;
  gap: 16px;
}

body[data-ui-mode="admin"] #category-section.is-collapsed .panel-heading {
  margin-bottom: 0;
}

body[data-ui-mode="admin"] #category-section-content[hidden] {
  display: none !important;
}

#upload-section-content {
  display: grid;
  gap: 16px;
}

body[data-ui-mode="user"]:not(.user-details-expanded) .validation-table .line-analysis-meta,
body[data-ui-mode="user"]:not(.user-details-expanded) .validation-table .history-debug {
  display: none !important;
}

body[data-ui-mode="user"] .user-upload-hero {
  display: none !important;
}

body[data-ui-mode="user"] .user-upload-hero-copy {
  display: grid;
  gap: 6px;
}

body[data-ui-mode="user"] .user-upload-hero-copy strong {
  font-size: 20px;
  line-height: 1.2;
  color: #111827;
}

body[data-ui-mode="user"] .user-upload-hero-copy span,
body[data-ui-mode="user"] .user-upload-hero-formats {
  color: #475569;
  font-size: 14px;
  line-height: 1.5;
}

body[data-ui-mode="user"] .workflow-steps {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 18px;
}

body[data-ui-mode="user"] .workflow-step {
  padding: 0;
}

body[data-ui-mode="user"] .workflow-step + .workflow-step {
  border-top: 0;
}

body[data-ui-mode="user"] .dashboard-strip,
body[data-ui-mode="admin"] .dashboard-strip {
  gap: 10px;
  margin-bottom: 0;
}

body[data-ui-mode="user"] .app-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding-inline: 0;
  box-sizing: border-box;
}

body[data-ui-mode="user"] .kpi-card,
body[data-ui-mode="admin"] .kpi-card {
  padding: 14px 16px;
}

body[data-ui-mode="user"] .kpi-card strong,
body[data-ui-mode="admin"] .kpi-card strong {
  margin-top: 6px;
  font-size: 22px;
}

body[data-ui-mode="user"] .container {
  display: flex;
  flex-direction: column;
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 24px 0 56px;
}

body[data-ui-mode="user"] #analytics-section {
  order: 1;
}

body[data-ui-mode="user"] #check-section {
  order: 1;
}

body[data-ui-mode="user"] #upload-section {
  order: 3;
}

body[data-ui-mode="user"] #history-section {
  order: 2;
}

body[data-ui-mode="user"] #upload-section,
body[data-ui-mode="user"] #check-section {
  scroll-margin-top: 32px;
}

body[data-ui-mode="user"] #history-section {
  scroll-margin-top: 32px;
}

body[data-ui-mode="user"] .sidebar,
body[data-ui-mode="user"] .mobile-topbar {
  display: none !important;
}

body[data-ui-mode="user"] .app-topbar {
  padding-inline: 0;
}

body[data-ui-mode="user"] .panel,
body[data-ui-mode="user"] .table-wrap,
body[data-ui-mode="user"] .history-table-wrap,
body[data-ui-mode="admin"] .panel,
body[data-ui-mode="admin"] .table-wrap,
body[data-ui-mode="admin"] .history-table-wrap {
  width: 100%;
  max-width: none;
}

body[data-ui-mode="user"] .page-container > .panel,
body[data-ui-mode="user"] .page-container > .sticky-stats-bar {
  width: 100%;
}

body[data-ui-mode="user"] .panel,
body[data-ui-mode="admin"] .panel {
  padding: 22px;
  margin-bottom: 20px;
}

body[data-ui-mode="admin"] .panel-heading,
body[data-ui-mode="user"] #upload-section .panel-heading,
body[data-ui-mode="user"] #check-section .panel-heading {
  margin-bottom: 14px;
}

body[data-ui-mode="user"] .panel h2,
body[data-ui-mode="admin"] .panel h2 {
  font-size: 20px;
}

body[data-ui-mode="admin"] .container {
  max-width: none;
  width: auto;
  padding: 24px 24px 56px;
}

body[data-ui-mode="admin"] .app-topbar {
  padding-inline: 0;
}

body[data-ui-mode="admin"] .app-topbar-inner,
body[data-ui-mode="admin"] .container.page-container {
  width: calc(100% - 252px);
  max-width: 1760px;
  margin-left: 252px;
  margin-right: auto;
  padding-left: 36px;
  padding-right: 36px;
}

body[data-ui-mode="admin"] .container.page-container {
  padding-top: 24px;
  padding-bottom: 56px;
}

body[data-ui-mode="user"] .section-help,
body[data-ui-mode="admin"] .section-help {
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.4;
}

body[data-ui-mode="admin"] #failed-section,
body[data-ui-mode="admin"] #problem-document-review-section,
body[data-ui-mode="admin"] #reprocessing-section,
body[data-ui-mode="admin"] #category-section,
body[data-ui-mode="admin"] #documents-admin-section {
  scroll-margin-top: 32px;
}

body[data-ui-mode="user"] #upload-form {
  grid-template-columns: 1fr;
  gap: 10px;
}

body[data-ui-mode="user"] #validate-form {
  grid-template-columns: 1fr;
  gap: 10px;
}

body[data-ui-mode="user"] .upload-documents-block.uploaded-documents-block,
body[data-ui-mode="user"] .beta-notice {
  display: none !important;
}

body[data-ui-mode="user"] #upload-form .file-input-button,
body[data-ui-mode="user"] #validate-form .file-input-button,
body[data-ui-mode="user"] #validate-form button[type="submit"] {
  min-height: 38px;
  height: 38px;
  padding-inline: 14px;
  font-size: 15px;
}

body[data-ui-mode="user"] #check-section {
  border-color: #cfd8e3;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

body[data-ui-mode="user"] #upload-section {
  border-color: #e2e8f0;
}

body[data-ui-mode="user"] #upload-section.is-collapsed {
  background: #ffffff;
}

body[data-ui-mode="user"] #upload-section.is-collapsed .panel-heading {
  margin-bottom: 0;
}

body[data-ui-mode="user"] #upload-section-content[hidden] {
  display: none !important;
}

body[data-ui-mode="user"] .home-upload-panel .upload-documents-block {
  margin: 0;
  padding-top: 4px;
  border-top: 1px solid #eef2f7;
}

body[data-ui-mode="user"] .home-upload-panel .upload-summary-grid {
  gap: 10px;
  margin-bottom: 12px;
}

body[data-ui-mode="user"] .home-upload-panel .summary-card {
  padding: 12px;
}

body[data-ui-mode="user"] .home-upload-panel .summary-card strong {
  font-size: 18px;
}

body[data-ui-mode="user"] .home-upload-panel .section-head {
  margin-bottom: 10px;
}

body[data-ui-mode="user"] #validation-results-shell[hidden] {
  display: none !important;
}

body[data-ui-mode="user"] #validation-results-shell {
  margin-top: 14px;
}

.upload-review-items-wrap {
  margin-bottom: 16px;
}

.reprocessing-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.summary-grid-reprocessing {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.reprocessing-progress-grid {
  margin-bottom: 16px;
}

.upload-multi-stats span {
  display: block;
  margin-bottom: 6px;
  color: #6b7280;
  font-size: 12px;
}

.upload-status-ready {
  color: #166534;
  font-weight: 700;
}

.upload-status-review {
  color: #9a3412;
  font-weight: 700;
}

.upload-status-detecting {
  color: #1d4ed8;
  font-weight: 700;
}

.inline-warning {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface-muted);
  color: var(--cp-text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.soft-save-prompt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0;
  padding: 16px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-lg);
  background: var(--cp-surface);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.soft-save-prompt[hidden] {
  display: none !important;
}

.soft-save-prompt h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.soft-save-prompt p {
  margin: 0;
  color: var(--cp-text-muted);
  font-size: 14px;
  line-height: 1.45;
}

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

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

.soft-save-form label {
  display: grid;
  gap: 6px;
  color: var(--cp-text);
  font-size: 14px;
  font-weight: 700;
}

.soft-save-tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface-muted);
}

.soft-save-tab {
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: calc(var(--cp-radius-md) - 3px);
  background: transparent;
  color: var(--cp-text-muted);
  font-weight: 700;
}

.soft-save-tab.is-active {
  background: var(--cp-surface);
  color: var(--cp-text);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.soft-save-error {
  margin: 0;
}

.document-status-active {
  color: #166534;
  font-weight: 700;
}

.document-status-ready {
  color: #166534;
  font-weight: 700;
}

.document-status-partial {
  color: #9a3412;
  font-weight: 700;
}

.document-status-error {
  color: #b91c1c;
  font-weight: 700;
}

.document-status-duplicate {
  color: #475569;
  font-weight: 700;
}

.document-status-excluded {
  color: #6b7280;
  font-weight: 700;
}

.table-action-cell {
  white-space: nowrap;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, 0.4);
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none !important;
}

body.modal-open {
  overflow: hidden;
}

.modal-card {
  width: min(100%, 420px);
  padding: 20px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-lg);
  background: var(--cp-surface);
  box-sizing: border-box;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.10);
}

.modal-overlay-side {
  justify-content: flex-end;
  padding: 0;
}

.modal-side-panel {
  width: min(100%, 760px);
  height: 100vh;
  max-height: 100vh;
  border-radius: 0;
  overflow: auto;
  padding: 20px 20px 28px;
}

.document-details-content {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

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

.document-details-subtitle {
  margin-top: 6px;
  color: #6b7280;
  font-size: 13px;
}

.document-details-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  color: #111827;
}

.document-details-section {
  display: grid;
  gap: 12px;
}

.document-metadata-editor {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: #f8fafc;
}

.document-metadata-form {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.validation-document-metadata-editor {
  margin-top: 12px;
}

.document-metadata-helper {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
}

.document-metadata-helper.is-missing {
  color: #b45309;
}

.document-details-table-wrap {
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface);
}

.document-file-meta {
  display: grid;
  gap: 10px;
}

.document-file-meta span {
  color: #6b7280;
}

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

.ghost-button {
  padding: 6px 10px;
  border: 1px solid var(--cp-border);
  border-radius: 8px;
  background: var(--cp-surface);
  color: #374151;
  font-size: 12px;
}

.ghost-button:hover:not(:disabled) {
  background: #f8fafc;
}

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

.version-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow-soft);
}

.version-history-main {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.version-history-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.version-history-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: #64748b;
  font-size: 13px;
}

.version-history-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.version-history-merged {
  width: 100%;
  margin-top: 4px;
}

.version-history-merged-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.version-history-merged-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 8px;
  border-top: 1px solid var(--cp-border);
}

.comparison-inline-meta {
  color: #64748b;
  font-size: 12px;
}

.comparison-parameter-list {
  display: grid;
  gap: 6px;
  min-width: 220px;
  color: #334155;
}

.version-comparison-panel {
  display: grid;
  gap: 12px;
}

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

.modal-card h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.modal-close-button {
  border: 0;
  background: transparent;
  color: #6b7280;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  padding: 0;
}

.modal-close-button:hover {
  color: #374151;
}

.modal-close-button:active {
  color: #111827;
}

.modal-card p {
  margin: 0;
  color: #4b5563;
  font-size: 14px;
  line-height: 1.5;
}

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

.onboarding-card {
  max-width: 460px;
  padding: 22px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

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

.onboarding-progress {
  margin-bottom: 14px;
}

.onboarding-progress span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #dbe3ee;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
}

.onboarding-content h3 {
  margin: 0 0 10px;
  font-size: 24px;
  line-height: 1.2;
}

.onboarding-content p {
  margin: 0;
  color: #475569;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-line;
}

.onboarding-actions {
  margin-top: 22px;
  justify-content: space-between;
}

.onboarding-form {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.onboarding-form label {
  display: grid;
  gap: 8px;
  color: var(--cp-text);
  font-size: 14px;
  font-weight: 600;
}

.onboarding-form input,
.onboarding-form select {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--cp-border-strong);
  border-radius: 10px;
  background: var(--cp-surface);
  color: var(--cp-text);
  font: inherit;
  box-sizing: border-box;
}

.onboarding-error {
  margin: -4px 0 0;
  color: #b91c1c;
  font-size: 13px;
  line-height: 1.5;
}

.type-panel {
  padding: 14px 16px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface-muted);
}

.type-panel-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.type-panel-label {
  color: #6b7280;
  font-weight: 400;
}

.type-panel-note {
  margin: 8px 0 0;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.4;
}

.parser-debug-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px 12px;
  margin-bottom: 10px;
}

.parser-debug-grid span {
  color: #6b7280;
}

.parser-debug-preview {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--cp-surface);
  border: 1px solid var(--cp-border);
  color: #374151;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
}

.parser-debug-details {
  margin-top: 10px;
}

.parser-debug-details summary {
  cursor: pointer;
  color: #1d4ed8;
  font-size: 13px;
  user-select: none;
  margin-bottom: 8px;
}

.validation-summary-note {
  margin: 16px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow-soft);
}

.validation-version-actions {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
}

.validation-summary-note strong {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
}

.validation-summary-details {
  color: #4b5563;
  font-size: 13px;
  line-height: 1.5;
}

.validation-attention-summary {
  display: grid;
  gap: 12px;
}

.validation-attention-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.validation-attention-metric {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--cp-border);
  border-radius: 12px;
  background: #f8fafc;
}

.validation-attention-metric span {
  font-size: 12px;
  color: #64748b;
}

.validation-attention-metric strong {
  margin: 0;
  font-size: 20px;
  line-height: 1.2;
  color: #111827;
}

.validation-attention-metric-alert {
  border-color: #f5d9a6;
  background: #fffbeb;
}

.validation-attention-explanation {
  color: #334155;
  font-size: 13px;
  line-height: 1.5;
}

.validation-attention-breakdown {
  margin: 0;
  padding-top: 2px;
}

.validation-attention-breakdown summary {
  cursor: pointer;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

.validation-attention-breakdown-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.validation-attention-breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid #e5e7eb;
}

.validation-attention-breakdown-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.validation-attention-breakdown-row span {
  color: #475569;
}

.validation-attention-breakdown-row strong {
  margin: 0;
  font-size: 13px;
  color: #111827;
}

.analysis-loading-state {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface-muted);
  box-shadow: var(--cp-shadow-soft);
}

.analysis-loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-top-color: #374151;
  border-radius: 999px;
  flex: 0 0 auto;
  animation: costpilot-spin 0.8s linear infinite;
}

.analysis-loading-copy {
  display: grid;
  gap: 2px;
}

.analysis-loading-copy strong {
  font-size: 14px;
  color: #111827;
}

.analysis-loading-copy span {
  font-size: 12px;
  color: #4b5563;
}

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

.detection-status {
  margin: -4px 0 0;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.4;
}

.status-line {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.4;
}

.status-line.is-loading {
  color: #334155;
}

.status-line.is-success {
  color: #166534;
}

.status-line.is-error {
  color: #b45309;
}

.status-line .analysis-loading-spinner {
  width: 14px;
  height: 14px;
  border-width: 2px;
  border-color: rgba(55, 65, 81, 0.22);
  border-top-color: #374151;
  flex: 0 0 auto;
}

.process-steps {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

#validate-process-steps {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.process-step {
  padding: 10px 12px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-sm);
  background: var(--cp-surface-muted);
  color: var(--cp-text-soft);
  font-size: 12px;
  font-weight: 600;
}

.process-step.is-active {
  border-color: #374151;
  color: #374151;
  background: #ffffff;
}

.process-step.is-done {
  border-color: #9ca3af;
  color: #111827;
  background: #ffffff;
}

.process-step.is-error {
  border-color: #b91c1c;
  color: #b91c1c;
  background: #ffffff;
}

.analysis-summary-block {
  margin: 10px 0 12px;
  padding: 12px;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-lg);
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow-soft);
}

.analysis-summary-block.is-sticky-ready {
  position: static;
  top: auto;
  z-index: auto;
  padding: 18px;
  border-color: var(--cp-border);
  box-shadow: var(--cp-shadow-soft);
}

.analysis-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.analysis-summary-header h3 {
  margin: 0;
  font-size: 16px;
}

.analysis-summary-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.analysis-status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.analysis-status-chip.tone-success {
  background: #dcfce7;
  color: #166534;
}

.analysis-status-chip.tone-warning {
  background: #fef3c7;
  color: #92400e;
}

.analysis-status-chip.tone-neutral {
  background: #e5e7eb;
  color: #374151;
}

.analysis-summary-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.45fr) repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.analysis-summary-total {
  grid-column: span 1;
}

.analysis-summary-grid .summary-card-featured {
  grid-column: span 1;
}

.analysis-summary-secondary {
  display: none;
}

.analysis-summary-grid .summary-card {
  padding: 10px 12px;
}

.analysis-summary-grid .summary-label,
.summary-grid-compact .summary-label {
  margin-bottom: 4px;
}

.analysis-summary-grid .summary-card strong {
  font-size: 20px;
}

.analysis-summary-block.is-sticky-ready .analysis-summary-header {
  align-items: center;
  margin-bottom: 10px;
}

.analysis-summary-block.is-sticky-ready .analysis-summary-header h3 {
  font-size: 15px;
}

.analysis-summary-block.is-sticky-ready .analysis-status-chip {
  min-height: 26px;
  padding: 0 10px;
  font-size: 12px;
}

.analysis-summary-block.is-sticky-ready .analysis-summary-grid {
  grid-template-columns: minmax(180px, 1.4fr) repeat(5, minmax(110px, 1fr));
  gap: 10px;
}

.analysis-summary-block.is-sticky-ready .summary-card {
  padding: 10px 12px;
}

.analysis-summary-block.is-sticky-ready .summary-card strong {
  font-size: 15px;
  line-height: 1.3;
}

.analysis-summary-block.is-sticky-ready .summary-label {
  font-size: 11px;
}

.analysis-summary-block.is-sticky-ready .summary-card-featured {
  grid-column: span 1;
}

.history-trend {
  margin: 0 0 16px;
  padding: 16px;
  background: var(--cp-surface-muted);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
}

.history-trend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 13px;
}

.history-trend-track {
  height: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

.history-trend-fill {
  width: 0%;
  height: 100%;
  border-radius: 999px;
  background: #111827;
}

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

.summary-grid-compact {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: stretch;
}

.summary-grid-compact .summary-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  box-sizing: border-box;
  min-height: 58px;
  padding: 10px 12px;
}

.summary-grid-compact .summary-card strong,
.summary-grid-compact .summary-value-button {
  font-size: 22px;
}

.summary-grid-history {
  margin-top: 0;
}

.summary-card {
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  padding: 14px 16px;
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow-soft);
}

.summary-label-with-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.summary-label {
  display: block;
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 6px;
}

.summary-card strong {
  display: block;
  font-size: 22px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.summary-value-button {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: auto;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  color: #111827;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}

.summary-value-button:hover:not(:disabled) {
  color: var(--cp-accent);
}

.summary-value-button:disabled {
  color: #111827;
  cursor: default;
}

.summary-value-button[aria-disabled="true"],
.summary-value-button.is-empty {
  color: #111827;
  cursor: default;
  background: transparent;
  box-shadow: none;
}

.info-tooltip-button {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #fff;
  color: #475569;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  cursor: help;
}

.info-tooltip-button::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  width: min(260px, 70vw);
  padding: 8px 10px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 5;
}

.info-tooltip-button:hover::after,
.info-tooltip-button:focus-visible::after {
  opacity: 1;
}

.savings-breakdown {
  display: none;
  gap: 8px;
  margin: 0;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: var(--cp-radius-md);
  background: #f8fafc;
}

.savings-breakdown:not([hidden]) {
  display: grid;
  margin: 8px 0 14px;
}

.savings-breakdown-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  color: #334155;
  font-size: 13px;
}

.savings-breakdown-row span {
  flex: 1 1 auto;
}

.savings-breakdown-row strong {
  display: block;
  flex: 0 0 auto;
  margin: 0;
  font-size: 13px;
  color: #111827;
}

.savings-breakdown-total {
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
}

.summary-card-featured {
  grid-column: span 2;
  background: #ffffff;
}

.summary-card-alert {
  background: #ffffff;
  border-color: #d8e1ec;
}

.results-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 16px;
}

.validation-results-head {
  margin-top: 4px;
}

.history-results-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 16px;
  color: #374151;
  font-size: 14px;
}

.history-results-meta strong {
  display: inline-block;
}

.history-current-row td {
  background: #f8fafc;
  box-shadow: inset 0 1px 0 rgba(100, 116, 139, 0.18), inset 0 -1px 0 rgba(100, 116, 139, 0.18);
}

.history-current-row td:first-child {
  box-shadow: inset 3px 0 0 #64748b, inset 0 1px 0 rgba(100, 116, 139, 0.18), inset 0 -1px 0 rgba(100, 116, 139, 0.18);
}

.history-current-row-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.history-results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.history-excluded-count {
  color: #6b7280;
  font-size: 13px;
}

.history-action-cell {
  width: 112px;
}

.history-exclude-button {
  white-space: nowrap;
}

@media (max-width: 960px) {
  .history-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-button {
  background: var(--cp-surface);
  color: #374151;
  border: 1px solid var(--cp-border);
  padding: 8px 12px;
  border-radius: var(--cp-radius-sm);
}

.filter-button.filter-all {
  background: #f9fafb;
}

.filter-button.filter-ok {
  background: #f9fafb;
  color: #166534;
  border-color: #d1d5db;
}

.filter-button.filter-suspicious {
  background: #f9fafb;
  color: #9a3412;
  border-color: #d1d5db;
}

.filter-button.filter-overpriced {
  background: #f9fafb;
  color: #b91c1c;
  border-color: #d1d5db;
}

.filter-button.filter-low-confidence {
  background: #f9fafb;
  color: #1d4ed8;
  border-color: #d1d5db;
}

.filter-button.filter-unknown {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #d1d5db;
}

.filter-button.active {
  background: #475569;
  color: #ffffff;
  border-color: #475569;
  box-shadow: none;
}

.filter-button:hover:not(.active) {
  background: #f8fafc;
}

.filter-button:active:not(:disabled) {
  background: #e5e7eb;
}

.failed-filter-button {
  background: var(--cp-surface);
  color: #374151;
  border: 1px solid var(--cp-border);
  padding: 8px 12px;
  border-radius: var(--cp-radius-sm);
}

.failed-filter-button.failed-filter-new {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fca5a5;
}

.failed-filter-button.failed-filter-review {
  background: #fef3c7;
  color: #92400e;
  border-color: #fcd34d;
}

.failed-filter-button.failed-filter-fixed {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.failed-filter-button.failed-filter-false-positive {
  background: #e0f2fe;
  color: #075985;
  border-color: #7dd3fc;
}

.failed-filter-button.failed-filter-ignored {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #d1d5db;
}

.failed-filter-button.active {
  background: #475569;
  color: #ffffff;
  border-color: #475569;
  box-shadow: none;
}

.failed-filter-button:hover:not(.active) {
  filter: brightness(0.98);
}

.failed-filter-button:active:not(:disabled) {
  filter: brightness(0.95);
}

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

.history-table-wrap {
  max-height: 64vh;
  overflow: auto;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface);
  box-shadow: var(--cp-shadow);
}

.history-table-wrap .history-table {
  min-width: 1080px;
}

.history-table-wrap .history-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
}

.validation-table-wrap {
  max-height: 620px;
  overflow: auto;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface);
}

.validation-table {
  min-width: 920px;
}

.validation-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafb;
}

.compact-table th,
.compact-table td {
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.45;
}

.compact-table th:first-child,
.compact-table td:first-child {
  min-width: 300px;
  width: 28%;
}

.validation-row-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #dbe2ea;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.validation-row-toggle:hover {
  color: var(--cp-accent);
}

.validation-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.validation-item-name-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: #0f172a;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(55, 65, 81, 0.22);
  text-underline-offset: 0.14em;
  transition: color 0.18s ease, text-decoration-color 0.18s ease, background-color 0.18s ease;
}

.validation-item-name-button:hover {
  color: var(--cp-accent);
  text-decoration-color: currentColor;
}

.validation-details-row td {
  padding-top: 0;
  background: #fbfdff;
}

.validation-details-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  padding: 14px 16px;
  border: 1px solid #dbe7f3;
  border-radius: 12px;
  background: #f8fbff;
}

.validation-details-card div {
  display: grid;
  gap: 4px;
}

.validation-details-card span {
  color: #64748b;
  font-size: 12px;
}

.validation-details-card strong {
  font-size: 13px;
  line-height: 1.5;
  font-weight: 600;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #e7edf4;
  text-align: left;
  font-size: 13px;
  line-height: 1.45;
  vertical-align: top;
}

th {
  height: 52px;
  padding: 14px 16px;
  background: var(--cp-surface-muted);
  color: #475569;
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}

.empty-state-cell {
  padding: 28px 20px;
}

.empty-state {
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--cp-text-soft);
  justify-items: center;
  max-width: 520px;
  margin: 0 auto;
}

.empty-state strong {
  color: #0f172a;
  font-size: 16px;
}

.empty-state span {
  font-size: 14px;
  line-height: 1.55;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #f3f4f6;
  color: #166534;
}

.badge.suspicious {
  background: #f3f4f6;
  color: #92400e;
}

.badge.overpriced {
  background: #f3f4f6;
  color: #991b1b;
}

.badge.unknown_item {
  background: #f3f4f6;
  color: #374151;
}

.badge.low_confidence_match {
  background: #f3f4f6;
  color: #1d4ed8;
}

.badge.low_confidence_color {
  background: #fef9c3;
  color: #854d0e;
}

.badge.low_confidence_size {
  background: #ffedd5;
  color: #9a3412;
}

.badge.low_confidence_weak {
  background: #fee2e2;
  color: #991b1b;
}

.badge.failed-document-new {
  background: #fee2e2;
  color: #991b1b;
}

.badge.failed-document-in-review {
  background: #fef3c7;
  color: #92400e;
}

.badge.failed-document-fixed {
  background: #dcfce7;
  color: #166534;
}

.badge.failed-document-false-positive {
  background: #e0f2fe;
  color: #075985;
}

.badge.failed-document-ignored {
  background: #e5e7eb;
  color: #374151;
}

.failed-document-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.failed-document-meta {
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.4;
}

.failed-document-attempts {
  font-weight: 700;
}

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

.failed-document-system-warning,
.problem-document-review-banner {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  background: #fffbeb;
  color: #92400e;
}

.failed-document-review-row td {
  padding-top: 0;
}

.failed-document-review-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--cp-border);
  border-radius: 12px;
  background: #f8fafc;
}

.failed-document-review-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.failed-document-review-grid div,
.failed-document-review-note {
  min-width: 0;
}

.failed-document-review-grid span,
.failed-document-review-note span {
  display: block;
  margin-bottom: 4px;
  color: #6b7280;
  font-size: 12px;
}

.failed-document-review-grid strong,
.failed-document-review-note strong {
  display: block;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.failed-document-tech-details {
  display: grid;
  gap: 8px;
}

.failed-document-tech-details summary {
  cursor: pointer;
  color: #1d4ed8;
  font-size: 13px;
  user-select: none;
}

.failed-document-tech-details pre {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: #111827;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.failed-document-inline-technical-details {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  border-radius: 10px;
  background: #111827;
  color: #e5e7eb;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.problem-document-review-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.problem-document-review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  margin-bottom: 18px;
  width: 100%;
  max-width: 100%;
  align-items: start;
}

.problem-document-preview-panel,
.problem-document-form-panel,
.problem-document-rows-panel {
  border: 1px solid var(--cp-border);
  border-radius: 14px;
  background: var(--cp-surface);
  padding: 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.problem-document-preview-panel h3,
.problem-document-rows-panel h3 {
  margin: 0 0 12px;
}

.problem-document-preview-frame-wrap,
.problem-document-preview-image-wrap,
.problem-document-preview-table-wrap {
  position: relative;
  border: 1px solid var(--cp-border);
  border-radius: 12px;
  overflow: hidden;
  background: #f8fafc;
}

.problem-document-preview-table-wrap {
  max-height: 640px;
  overflow: auto;
}

.problem-document-preview-frame {
  width: 100%;
  min-height: 640px;
  border: 0;
  background: #ffffff;
}

.problem-document-preview-image {
  display: block;
  max-width: 100%;
  height: auto;
}

.problem-document-preview-table {
  width: 100%;
  border-collapse: collapse;
}

.problem-document-preview-table td {
  min-width: 120px;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  font-size: 13px;
  vertical-align: top;
}

.problem-document-preview-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.problem-document-preview-empty {
  display: grid;
  gap: 6px;
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  color: #475569;
  background: #f8fafc;
}

.problem-document-preview-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(248, 250, 252, 0.96);
  color: #475569;
  z-index: 1;
}

.problem-document-preview-frame-wrap.is-loaded .problem-document-preview-loading {
  display: none;
}

.problem-document-preview-error {
  margin: 12px;
}

.problem-document-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.problem-document-quick-apply {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--cp-border);
  border-radius: 12px;
  background: #f8fafc;
}

.problem-document-quick-apply-head h3 {
  margin: 0 0 4px;
}

.problem-document-quick-apply-head {
  display: grid;
  gap: 4px;
}

.problem-document-quick-apply-head p {
  margin: 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.5;
}

.problem-document-quick-apply-textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.problem-document-quick-apply-message {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.problem-document-quick-apply-message.is-success {
  color: #166534;
}

.problem-document-quick-apply-message.is-warning {
  color: #92400e;
}

.problem-document-quick-apply-message.is-error {
  color: #b91c1c;
}

.problem-document-form-grid label,
.problem-document-form-notes {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #475569;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.problem-document-form-grid > label:first-child {
  grid-column: 1 / -1;
}

.problem-document-form-notes {
  margin-top: 12px;
  width: 100%;
  max-width: 100%;
}

.problem-document-summary-card,
.problem-document-confirmation-card,
.problem-document-post-save {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--cp-border);
  border-radius: 12px;
  background: #ffffff;
}

.problem-document-summary-card h3 {
  margin: 0;
}

.problem-document-confirmation-card {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.problem-document-confirmation-card h3,
.problem-document-confirmation-card p {
  margin: 0;
}

.problem-document-confirmation-card p {
  color: #475569;
  font-size: 13px;
  line-height: 1.5;
}

.problem-document-summary-inline {
  margin: 0;
  color: #0f172a;
  font-size: 14px;
  line-height: 1.5;
}

.problem-document-summary-list {
  display: grid;
  gap: 10px;
}

.problem-document-summary-list div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.problem-document-summary-list div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.problem-document-summary-list span {
  color: #475569;
  font-size: 13px;
}

.problem-document-summary-list strong {
  text-align: right;
}

.problem-document-final-state {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--cp-border);
}

.problem-document-final-state-success {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.problem-document-final-state-warning {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}

.problem-document-final-state-error {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.problem-document-final-state-checklist {
  display: grid;
  gap: 8px;
}

.problem-document-final-state-checklist .is-done,
.problem-document-final-state-checklist .is-pending,
.problem-document-final-state-reason {
  font-size: 13px;
  line-height: 1.5;
}

.problem-document-final-state-checklist .is-done::before {
  content: "✓ ";
}

.problem-document-final-state-checklist .is-pending::before {
  content: "• ";
}

.problem-document-final-state-reason {
  margin: 0;
}

.problem-document-manual-edit {
  margin-top: 16px;
  border: 1px solid var(--cp-border);
  border-radius: 12px;
  background: #ffffff;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

.problem-document-manual-edit summary {
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 600;
}

.problem-document-manual-edit-body {
  display: grid;
  gap: 16px;
  padding: 0 16px 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  overflow-x: hidden;
}

.problem-document-post-save-note {
  margin: 0;
  color: #475569;
  font-size: 13px;
}

.problem-document-status-actions,
.problem-document-review-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.problem-document-primary-action {
  min-width: 220px;
}

.problem-document-rows-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.problem-document-form-panel,
.problem-document-preview-panel,
.problem-document-manual-edit-body > * ,
.problem-document-rows-panel,
.problem-document-rows-table,
.problem-document-rows-table th,
.problem-document-rows-table td {
  min-width: 0;
}

.problem-document-form-panel input,
.problem-document-form-panel textarea,
.problem-document-form-panel select,
.problem-document-rows-table input {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.problem-document-form-panel textarea {
  max-width: 100%;
}

.problem-document-rows-table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}

.problem-document-rows-table th,
.problem-document-rows-table td {
  overflow-wrap: anywhere;
}

.problem-document-rows-panel .table-wrap {
  width: 100%;
  max-width: 100%;
}

@media (max-width: 1180px) {
  .problem-document-review-layout {
    grid-template-columns: 1fr;
  }
}

.problem-document-empty-rows p {
  margin: 0 0 12px;
  color: #475569;
}

.history-category-select {
  min-width: 180px;
  width: 100%;
}

.category-management-form {
  grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr) auto;
  align-items: end;
}

.category-management-actions {
  display: flex;
  align-items: end;
}

.category-management-table-wrap {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius-md);
  background: var(--cp-surface);
}

.category-management-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
}

.category-management-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.category-management-row input {
  min-width: 0;
}

.category-management-row button {
  white-space: nowrap;
}

.category-management-meta {
  color: #6b7280;
  font-size: 13px;
}

.validation-row.is-critical {
  background: #f9fafb;
  border-left: 3px solid #b91c1c;
}

.validation-row.is-warning {
  background: #fafafa;
  border-left: 3px solid #92400e;
}

.validation-row.is-muted {
  background: #fbfbfb;
  border-left: 3px solid #6b7280;
}

.validation-row.is-ok {
  background: #ffffff;
}

@media (max-width: 900px) {
  body[data-ui-mode="user"] .page-container {
    padding-left: 20px;
    padding-right: 20px;
  }

  .app-topbar {
    display: none;
  }

  .landing-section {
    min-height: auto;
    padding: 72px 20px;
  }

  .landing-hero {
    padding-top: 20px;
  }

  .landing-nav {
    margin-bottom: 54px;
  }

  .landing-hero-grid,
  .landing-steps,
  .landing-control-grid,
  .landing-benefits {
    grid-template-columns: 1fr;
  }

  .landing-hero-grid {
    gap: 36px;
  }

  .landing-hero-copy h1 {
    max-width: 12ch;
  }

  .landing-product-panel {
    max-width: 620px;
  }

  .landing-control-grid {
    gap: 10px;
  }

  .landing-step p {
    max-width: none;
  }

  .sidebar {
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
    width: 260px;
  }

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

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
  }

  .failed-document-review-grid {
    grid-template-columns: 1fr;
  }

  .problem-document-review-head,
  .problem-document-review-layout,
  .problem-document-form-grid,
  .problem-document-rows-head {
    grid-template-columns: 1fr;
  }

  .problem-document-review-head,
  .problem-document-rows-head {
    display: grid;
  }

  .problem-document-preview-frame {
    min-height: 420px;
  }

  .mobile-menu-button {
    padding: 8px 12px;
  }

  .container {
    margin-left: 0;
    padding: 20px 16px 40px;
  }

  body[data-ui-mode="admin"] .app-topbar-inner,
  body[data-ui-mode="admin"] .container.page-container {
    width: 100%;
    max-width: none;
    margin-left: 0;
    padding-left: 16px;
    padding-right: 16px;
  }

  body[data-ui-mode="admin"] .container.page-container {
    padding-top: 20px;
    padding-bottom: 40px;
  }

  body[data-ui-mode="user"] .mobile-topbar {
    display: none !important;
  }

  body[data-ui-mode="user"] .app-topbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 16px;
  }

  body[data-ui-mode="user"] .app-topbar-brand {
    justify-content: space-between;
  }

  body[data-ui-mode="user"] .app-topbar-brand span {
    display: none;
  }

  body[data-ui-mode="user"] .app-topbar-mode-switch {
    min-width: 0;
    width: 100%;
  }

  body[data-ui-mode="user"] .container {
    padding: 16px 0 36px;
  }

  .dashboard-strip {
    position: static;
  }

  .sticky-stats-bar {
    position: static;
    margin-bottom: 24px;
    padding: 0;
    box-shadow: none;
  }

  .page-header {
    grid-template-columns: 1fr;
  }

  .dashboard-strip,
  .process-steps,
  .analysis-summary-grid,
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upload-summary-grid,
  .upload-multi-stats,
  .documents-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .summary-card-featured {
    grid-column: span 2;
  }

  .analysis-summary-total {
    grid-column: span 2;
  }

  .history-table-wrap {
    max-height: none;
  }

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

@media (max-width: 640px) {
  body[data-ui-mode="user"] .page-container {
    padding-left: 16px;
    padding-right: 16px;
  }

  .landing-section {
    padding: 56px 14px;
  }

  .landing-hero {
    padding-top: 16px;
  }

  .landing-nav {
    gap: 12px;
    margin-bottom: 42px;
  }

  body[data-ui-mode="user"] .app-topbar {
    padding-inline: 14px;
  }

  .landing-hero-copy h1 {
    max-width: none;
    font-size: 31px;
  }

  .landing-lead {
    font-size: 17px;
  }

  .landing-actions {
    display: grid;
  }

  .landing-button {
    width: 100%;
  }

  .landing-benefits {
    grid-template-columns: 1fr;
  }

  .landing-table-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 6px;
  }

  .landing-panel-note {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .landing-result-panel,
  .landing-step,
  .landing-benefits article {
    padding: 18px;
  }

  .landing-step h3,
  .landing-benefits h3 {
    margin-top: 38px;
    font-size: 20px;
  }

  .landing-result-panel h2,
  .landing-section-heading h2 {
    font-size: 34px;
  }

  .container {
    padding: 16px 12px 32px;
  }

  .duplicate-notice {
    padding: 14px;
    border-radius: 12px;
  }

  .duplicate-notice-meta {
    gap: 6px;
  }

  .duplicate-notice-pill {
    width: 100%;
    justify-content: flex-start;
  }

  .panel,
  .page-header-copy,
  .workflow-steps,
  .analysis-summary-block {
    padding: 16px;
  }

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

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

  .history-form-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .process-steps,
  .analysis-summary-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .analysis-summary-total {
    grid-column: span 1;
  }

  .summary-grid-compact .summary-card {
    min-height: 0;
    padding: 16px;
  }

  .results-toolbar {
    align-items: stretch;
  }

  .import-stats {
    flex-direction: column;
    gap: 8px;
  }

  .upload-summary-grid,
  .upload-multi-stats,
  .documents-summary-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .analysis-summary-header,
  .panel-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .section-caption {
    text-align: left;
  }

  .hero-actions {
    flex-direction: column;
  }

  .validation-table {
    min-width: 760px;
  }

  .documents-browser-toolbar {
    grid-template-columns: 1fr;
  }

  .maintenance-report-metrics,
  .maintenance-report-snapshots {
    grid-template-columns: 1fr;
  }

  .documents-browser-table {
    display: none;
  }

  .documents-mobile-list {
    display: grid;
  }

  .documents-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .document-mobile-meta {
    grid-template-columns: 1fr 1fr;
  }

  .modal-overlay-side {
    justify-content: center;
    padding: 0;
  }

  .modal-side-panel {
    width: 100%;
    height: 100vh;
    padding: 16px;
  }

  .summary-card-featured {
    grid-column: span 1;
  }

  .analysis-summary-block.is-sticky-ready {
    position: static;
    top: auto;
    z-index: auto;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  }
}
