:root {
  color-scheme: light;
  --navy-950: #0b2538;
  --navy-800: #153f58;
  --navy-700: #1f566f;
  --ink: #102635;
  --muted-ink: #445f70;
  --paper: #f5f7f5;
  --surface: #ffffff;
  --surface-soft: #eef4f3;
  --line: #9eafb7;
  --line-soft: #d6e0e3;
  --amber: #d99100;
  --amber-soft: #fff2c7;
  --green: #0b6b55;
  --green-soft: #e2f3ed;
  --red: #9f2f28;
  --red-soft: #fce8e6;
  --focus: #005fcc;
  --shadow: 0 10px 28px rgba(11, 37, 56, .10);
  --radius: 12px;
  --content: 1280px;
  font-size: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}
button, input, textarea, select { font: inherit; }
button, a, summary, input, textarea, select { touch-action: manipulation; }
button, a, summary { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: fixed;
  z-index: 1000;
  inset-block-start: 8px;
  inset-inline-start: 8px;
  transform: translateY(-160%);
  background: var(--focus);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-weight: 800;
}
.skip-link:focus { transform: translateY(0); }

.masthead {
  min-height: 112px;
  padding: 24px max(24px, calc((100vw - var(--content)) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #fff;
  background: var(--navy-950);
  border-block-end: 6px solid var(--amber);
}
.brand-lockup { display: flex; align-items: center; gap: 16px; }
.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border: 3px solid var(--amber);
  border-radius: 50%;
  color: var(--amber);
  font-size: 1.7rem;
  font-weight: 900;
}
.brand-title { margin: 0; font-size: 1.55rem; font-weight: 900; }
.eyebrow, .section-kicker { margin: 0 0 4px; color: var(--amber); font-size: .82rem; font-weight: 900; letter-spacing: .04em; }
.test-badge { padding: 10px 16px; background: var(--amber); color: var(--navy-950); border-radius: 999px; font-weight: 900; }

main { width: min(var(--content), calc(100% - 32px)); margin: 36px auto 96px; }
h1, h2, h3, p { margin-block-start: 0; }
h1 { margin-block-end: 12px; font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.15; letter-spacing: -.025em; }
h2 { margin-block-end: 12px; font-size: clamp(1.55rem, 3vw, 2.1rem); line-height: 1.25; }
h3 { margin-block-end: 10px; font-size: 1.3rem; line-height: 1.3; }
.lead { max-width: 58ch; color: var(--muted-ink); font-size: 1.08rem; }
a { color: var(--navy-700); font-weight: 800; text-underline-offset: .18em; }

:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
  box-shadow: 0 0 0 2px #fff;
}

.login-panel, .workflow-stage, .case-hero, .page-heading, .case-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login-panel { max-width: 660px; margin: 7vh auto; padding: clamp(28px, 5vw, 52px); border-block-start: 8px solid var(--amber); }
.form-field { margin-block: 24px; }
label, .field-label { display: block; margin-block-end: 8px; font-weight: 800; }
input, textarea, select {
  width: 100%;
  min-height: 52px;
  border: 2px solid #748a96;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 14px;
}
textarea { resize: vertical; }
input[aria-invalid="true"], textarea[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--red); background: #fff8f7; }
.field-help { margin: 7px 0 0; color: var(--muted-ink); font-size: .9rem; }
.password-control { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

button {
  min-height: 50px;
  min-width: 50px;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 11px 22px;
  background: var(--navy-950);
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}
button:hover { background: var(--navy-800); }
button:active { background: #071d2c; }
button:disabled { cursor: not-allowed; opacity: .55; }
button.secondary, .quiet-button { background: #fff; color: var(--navy-950); border-color: var(--navy-800); }
button.secondary:hover, .quiet-button:hover { background: var(--surface-soft); }
button.danger { background: var(--red); }
.primary-action { width: 100%; }

.status { min-height: 1.7em; margin: 14px 0 0; color: var(--muted-ink); font-weight: 800; }
.status[data-state="error"] { color: var(--red); }
.status[data-state="success"] { color: var(--green); }

.page-heading { padding: 28px 32px; margin-block-end: 24px; }
.case-groups { display: grid; gap: 28px; }
.case-group h2 { font-size: 1.45rem; }
.case-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.case-card { padding: 24px; border-inline-start: 8px solid var(--amber); }
.case-card h3 { margin-block-end: 6px; }
.case-card .case-card-action { display: inline-flex; align-items: center; justify-content: center; min-height: 50px; margin-block-start: 12px; padding: 10px 20px; border-radius: 8px; background: var(--navy-950); color: #fff; text-decoration: none; }

.case-nav { margin-block-end: 16px; }
.case-hero { display: grid; grid-template-columns: 1fr minmax(280px, .65fr); gap: 28px; padding: clamp(24px, 4vw, 40px); border-block-start: 8px solid var(--amber); }
.case-summary { margin: 0; color: var(--muted-ink); }
.case-state { align-self: center; padding: 20px; background: var(--amber-soft); border-inline-start: 6px solid var(--amber); border-radius: 8px; }
.state-label { display: block; margin-block-end: 6px; font-size: .9rem; font-weight: 800; }
.case-state strong { display: block; font-size: 1.18rem; }

.progress {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin: 24px 0;
  padding: 0;
  list-style: none;
}
.progress li { min-height: 78px; padding: 12px; border: 2px solid var(--line); border-radius: 8px; background: #fff; font-size: .9rem; font-weight: 800; }
.progress li::before { content: attr(data-step); display: block; margin-block-end: 4px; color: var(--muted-ink); font-size: .78rem; }
.progress li.is-complete { border-color: var(--green); background: var(--green-soft); }
.progress li.is-current { border-color: var(--amber); box-shadow: inset 0 0 0 2px var(--amber); }
.progress li.is-future { color: #647780; background: #edf1f2; }

.global-message, .error-summary { margin: 20px 0; padding: 18px 22px; border-radius: 8px; }
.global-message { background: var(--green-soft); border-inline-start: 6px solid var(--green); }
.error-summary { background: var(--red-soft); border: 2px solid var(--red); }
.error-summary h2 { font-size: 1.25rem; }

.workflow-stage { margin-block-start: 22px; overflow: clip; }
section.workflow-stage { padding: 26px; }
.stage-heading, .stage-heading > div { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.stage-heading > div { justify-content: flex-start; }
.stage-number { flex: 0 0 auto; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--navy-950); color: #fff; font-weight: 900; }
.status-badge { padding: 7px 12px; border-radius: 999px; background: var(--amber-soft); color: var(--ink); font-weight: 900; }
details > summary { min-height: 82px; display: flex; align-items: center; gap: 14px; padding: 18px 24px; cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
#case-shell:not([hidden]) details > summary::after { content: "פתח"; margin-inline-start: auto; color: var(--navy-700); font-weight: 900; }
#case-shell:not([hidden]) details[open] > summary::after { content: "סגור"; }
details > summary small { display: block; color: var(--muted-ink); font-weight: 400; }
.stage-body { padding: 0 24px 28px; border-block-start: 1px solid var(--line-soft); }
.stage-body > :first-child { margin-block-start: 24px; }

.review-grid { display: grid; grid-template-columns: minmax(320px, .8fr) minmax(0, 1.5fr); gap: 24px; align-items: start; margin-block-start: 24px; }
.source-card, .review-card, .approval-card, .audit-card { min-width: 0; padding: 22px; border: 1px solid var(--line-soft); border-radius: 10px; background: #fff; }
.source-card { position: sticky; inset-block-start: 16px; }
.image-frame { display: grid; min-height: 280px; place-items: center; overflow: hidden; border: 2px solid var(--line); border-radius: 8px; background: #e3e9e9; }
.image-frame img { display: block; width: 100%; max-height: 500px; object-fit: contain; }
.metadata { margin: 18px 0 0; }
.metadata div, .approval-summary div { display: grid; grid-template-columns: minmax(120px, .4fr) 1fr; gap: 12px; padding: 10px 0; border-block-start: 1px solid var(--line-soft); }
dt { color: var(--muted-ink); font-weight: 800; }
dd { margin: 0; overflow-wrap: anywhere; }
.review-heading { display: flex; justify-content: space-between; gap: 20px; }
.reviewer { color: var(--muted-ink); }
.review-state { display: flex; flex-wrap: wrap; gap: 16px; margin-block-end: 12px; }
.guardrail { padding: 14px 16px; border-inline-start: 6px solid var(--amber); border-radius: 6px; background: var(--amber-soft); font-weight: 800; }
.review-fields { display: grid; gap: 16px; margin-block-start: 20px; }
.review-row { padding: 18px; border: 2px solid var(--line-soft); border-radius: 10px; background: #fff; }
.review-row.needs-attention { border-color: var(--amber); background: #fffdf4; }
.review-row.changed { border-color: var(--green); background: var(--green-soft); }
.review-row-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-block-end: 12px; }
.field-name { font-size: 1.08rem; font-weight: 900; }
.confidence { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 800; }
.confidence::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--green); }
.confidence.low::before { background: var(--amber); border: 2px solid var(--ink); }
.original-value { margin-block-end: 12px; padding: 12px; border-radius: 6px; background: var(--surface-soft); }
.original-value strong { display: block; font-size: .84rem; color: var(--muted-ink); }
.review-row .reason-wrap, .review-row .unknown-wrap, .review-row .serial-wrap { margin-block-start: 12px; }
.unknown-wrap label, .explicit-confirm, .confirmations label { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; }
.unknown-wrap input, .explicit-confirm input, .confirmations input { width: 24px; min-width: 24px; height: 24px; min-height: 24px; margin-block-start: 4px; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-block-start: 24px; }

fieldset { min-width: 0; margin: 24px 0; padding: 20px; border: 2px solid var(--line-soft); border-radius: 10px; }
legend { padding: 0 10px; font-size: 1.18rem; font-weight: 900; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.form-grid .wide { grid-column: 1 / -1; }
.radio-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.radio-cards label { min-height: 52px; display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 12px; border: 2px solid var(--line); border-radius: 8px; }
.radio-cards input { width: 24px; min-height: 24px; }
.defects-list { display: grid; gap: 14px; }
.defect-card { position: relative; padding: 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.defect-card-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 14px; }
.defect-card .wide { grid-column: 1 / -1; }
.remove-defect { background: var(--red); }
.save-strip { position: sticky; inset-block-end: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; border: 2px solid var(--navy-800); border-radius: 10px; background: #fff; box-shadow: 0 -8px 20px rgba(11,37,56,.08); }
.save-strip p { margin: 0; }

.report-preview { position: relative; width: min(850px, 100%); min-height: 720px; margin-inline: auto; padding: clamp(24px, 5vw, 58px); overflow: hidden; border: 1px solid #8b969c; background: #fff; box-shadow: var(--shadow); }
.report-preview h2 { text-align: center; }
.draft-watermark { position: absolute; inset-block-start: 28px; inset-inline-start: -48px; transform: rotate(-35deg); padding: 8px 68px; background: var(--red); color: #fff; font-weight: 900; }
.preview-section { margin-block: 24px; }
.preview-section h3 { padding-block-end: 6px; border-block-end: 2px solid var(--navy-950); }
.preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; }
.preview-item { padding: 8px 0; border-block-end: 1px solid var(--line-soft); }
.preview-item strong { display: block; color: var(--muted-ink); font-size: .85rem; }
.two-column { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.approval-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.signature-setup { margin-block: 20px; border: 2px solid var(--line); border-radius: 10px; }
.signature-setup > summary { min-height: 56px; padding: 12px 16px; font-weight: 900; background: var(--surface-soft); }
.signature-setup form { padding: 4px 18px 18px; }
.signature-setup input[type="file"] { min-height: 60px; padding-block: 10px; }
.professional-summary { margin-block: 18px; padding: 16px; border: 1px solid var(--line-soft); border-radius: 8px; background: var(--surface-soft); }
.professional-summary h4 { margin-block: 0 10px; font-size: 1.08rem; }
.button-link { display:inline-flex; align-items:center; justify-content:center; min-height:44px; padding:10px 16px; border:2px solid var(--ink); border-radius:6px; color:var(--ink); background:#fff; font-weight:800; text-decoration:none; }
.button-link:focus-visible { outline:3px solid var(--focus); outline-offset:3px; }
.technical-details { border-style: dashed; }
.technical-details summary { background: #f1f4f5; }
.audit-card ol, #dispatch-audit-list { padding-inline-start: 24px; }
.audit-card li, #dispatch-audit-list li { padding: 8px 0; border-block-end: 1px solid var(--line-soft); }

@media (max-width: 960px) {
  :root { font-size: 18px; }
  .progress { grid-template-columns: repeat(3, 1fr); }
  .case-hero, .review-grid, .two-column { grid-template-columns: 1fr; }
  .source-card { position: static; }
}

@media (max-width: 640px) {
  :root { font-size: 18px; }
  .masthead { align-items: flex-start; padding: 18px 16px; }
  .brand-mark { width: 44px; height: 44px; }
  .test-badge { padding: 7px 10px; font-size: .82rem; }
  main { width: min(100% - 20px, var(--content)); margin-block-start: 20px; }
  .login-panel, section.workflow-stage, .page-heading, .case-hero { padding: 22px 16px; }
  .password-control { grid-template-columns: 1fr; }
  .progress { grid-template-columns: repeat(2, 1fr); }
  .form-grid, .radio-cards, .defect-card-grid, .approval-summary, .preview-grid { grid-template-columns: 1fr; }
  .form-grid .wide, .defect-card .wide { grid-column: auto; }
  .stage-heading { align-items: flex-start; }
  .stage-heading > div { align-items: flex-start; }
  .actions { flex-direction: column; }
  .actions button { width: 100%; }
  .save-strip { position: static; flex-direction: column; align-items: stretch; }
  details > summary { padding: 16px; }
  .stage-body { padding: 0 16px 22px; }
  .report-preview { min-height: 540px; padding: 44px 18px 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

@media (forced-colors: active) {
  .case-state, .guardrail, .status-badge, .review-row { border: 2px solid CanvasText; }
  button { border-color: ButtonText; }
}

@media print {
  .masthead, .case-nav, .progress, .stage-heading, details > summary, button, .status, .test-badge { display: none !important; }
  body, main { background: #fff; margin: 0; width: 100%; }
  .report-preview { border: 0; box-shadow: none; width: 100%; min-height: 0; }
}
