:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #f7f9f8;
  --ink: #17201d;
  --muted: #65716d;
  --line: #d7dfdc;
  --green: #176b4d;
  --green-2: #0f5139;
  --teal: #0e7080;
  --amber: #9b6410;
  --red: #9b2f2f;
  --blue: #285d9f;
  --shadow: 0 14px 42px rgba(24, 42, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Roboto", "Noto Kufi Arabic", "Noto Sans Arabic", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body[data-lang="ar"] {
  direction: rtl;
}

body[data-lang="en"] {
  direction: ltr;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: #ffffff;
  color: var(--ink);
  border-inline-end: 1px solid var(--line);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.uae-flag-strip {
  display: grid;
  grid-template-columns: 22px 1fr 1fr 1fr;
  height: 8px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  direction: ltr;
}

.uae-flag-strip span:nth-child(1) {
  background: #ef3340;
}

.uae-flag-strip span:nth-child(2) {
  background: #009739;
}

.uae-flag-strip span:nth-child(3) {
  background: #ffffff;
}

.uae-flag-strip span:nth-child(4) {
  background: #000000;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border: 1px solid #b7d8ca;
  display: grid;
  place-items: center;
  font-weight: 800;
  background: #e6f3ed;
  color: var(--green-2);
}

.brand-title {
  font-size: 18px;
  font-weight: 800;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 2px;
}

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

.nav-item {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  min-height: 54px;
  text-align: start;
  padding: 0 14px;
  display: grid;
  align-content: center;
  gap: 2px;
}

.language-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--green-2);
  min-height: 42px;
  font-weight: 900;
}

.nav-item.active,
.nav-item:hover {
  background: #e8f4ee;
  color: var(--green-2);
  border-color: #b7d8ca;
}

.side-note {
  margin-top: auto;
  border: 1px solid #b7d8ca;
  background: #f3faf6;
  padding: 14px;
}

.side-note p {
  margin: 7px 0 0;
  color: #33423d;
  line-height: 1.45;
}

.office-session-card {
  border: 1px solid #b7d8ca;
  background: #f3faf6;
  padding: 12px;
  display: grid;
  gap: 5px;
}

.office-session-card span,
.office-session-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.office-session-card strong {
  color: var(--green-2);
  font-size: 16px;
}

.office-session-card small {
  color: #33423d;
  line-height: 1.35;
}

.office-session-card button {
  margin-top: 6px;
  min-height: 36px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--green-2);
  font-weight: 900;
}

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

.wayfinding {
  margin-bottom: 14px;
}

.wayfinding a {
  color: var(--green-2);
  font-weight: 900;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-top: 5px solid var(--green);
  padding: 18px;
  box-shadow: var(--shadow);
}

body.office-auth-locked {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(23, 107, 77, 0.08), rgba(14, 112, 128, 0.08)),
    var(--bg);
}

body.office-auth-locked .app-shell {
  display: block;
  min-height: 100vh;
}

body.office-auth-locked .sidebar {
  display: none !important;
}

body.office-auth-locked .main {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: clamp(18px, 5vw, 56px);
}

.office-auth-gate {
  max-width: 680px;
  width: min(100%, 680px);
  margin: 0 auto;
}

.office-auth-card {
  background: var(--surface);
  border: 1px solid #b7d8ca;
  border-top: 6px solid var(--green);
  padding: clamp(24px, 4vw, 38px);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.office-auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.office-auth-mark {
  width: 48px;
  height: 48px;
  border: 1px solid #b7d8ca;
  background: #e6f3ed;
  color: var(--green-2);
  display: grid;
  place-items: center;
  font-weight: 900;
}

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

.office-auth-brand strong {
  font-size: 18px;
  color: var(--ink);
}

.office-auth-brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.office-auth-rule {
  display: grid;
  grid-template-columns: 22px 1fr 1fr 1fr;
  height: 7px;
  direction: ltr;
}

.office-auth-rule span:nth-child(1) {
  background: #ef3340;
}

.office-auth-rule span:nth-child(2) {
  background: #009739;
}

.office-auth-rule span:nth-child(3) {
  background: #ffffff;
  border-block: 1px solid rgba(0, 0, 0, 0.08);
}

.office-auth-rule span:nth-child(4) {
  background: #000000;
}

.office-auth-card h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.08;
}

.office-auth-card p,
.office-auth-card small {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.office-auth-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.auth-notice {
  border: 1px solid #e0c4a0;
  background: #fff8ed;
  color: var(--amber);
  padding: 12px;
  font-weight: 800;
}

.eyebrow,
.note-label {
  margin: 0;
  color: var(--green);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar h1,
.section-head h2,
.modal h2 {
  margin: 4px 0 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 28px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 8px;
  min-width: 470px;
}

.metric-strip div {
  background: #fafcfb;
  border: 1px solid var(--line);
  padding: 12px;
}

.metric-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.metric-strip strong {
  font-size: 14px;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

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

.section-head p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.grid {
  display: grid;
  gap: 14px;
}

.two-column {
  grid-template-columns: minmax(0, 1.25fr) minmax(310px, 0.75fr);
}

.three-column {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 330px;
  gap: 14px;
}

.lower-grid {
  margin-top: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: 0 10px 26px rgba(24, 42, 36, 0.08);
  padding: 16px;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.highlight-panel {
  border-color: rgba(23, 107, 77, 0.35);
  background: #f3faf6;
}

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

label {
  display: grid;
  gap: 6px;
  color: #2f3b37;
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  min-height: 40px;
  padding: 9px 10px;
  color: var(--ink);
}

textarea {
  resize: vertical;
  line-height: 1.45;
}

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

.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
}

.checkline input {
  width: 17px;
  height: 17px;
  min-height: 0;
}

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

.document-controls span {
  display: block;
  font-size: 13px;
  font-weight: 800;
  margin-bottom: 6px;
}

.auto-prep-notice,
.auto-prep-status {
  border: 1px solid #bdd0ef;
  background: #f4f8fe;
  padding: 12px;
}

.auto-prep-notice p {
  margin: 8px 0 0;
  color: #34423d;
  line-height: 1.5;
}

.auto-prep-status {
  max-width: 430px;
  display: grid;
  gap: 7px;
}

.auto-prep-status strong {
  color: #34423d;
  font-size: 13px;
  line-height: 1.45;
}

.primary-action,
.secondary-action {
  min-height: 42px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 800;
}

.primary-action {
  background: var(--green);
  color: white;
}

.primary-action:hover {
  background: var(--green-2);
}

.secondary-action {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.full-width {
  width: 100%;
}

.case-picker {
  display: grid;
  min-width: 260px;
  gap: 8px;
  border: 1px solid #c8e3d6;
  background: #f3faf6;
  padding: 12px;
}

.case-picker label {
  color: var(--green-2);
  text-transform: uppercase;
  font-size: 11px;
}

.queue-stats {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.queue-stats strong {
  color: #33423d;
  font-size: 12px;
}

.check-list,
.detail-list,
.status-list,
.rule-list,
.compact-stack {
  display: grid;
  gap: 8px;
}

.check-item,
.detail-item,
.status-item,
.rule-item,
.queue-item {
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 10px;
}

.detail-item,
.rule-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.detail-item span,
.rule-item span {
  color: var(--muted);
}

.status-pill,
.mini-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  border: 1px solid transparent;
  white-space: nowrap;
}

.status-pill.pass,
.mini-pill.pass {
  color: var(--green-2);
  background: #e5f3ec;
  border-color: #b8ddcb;
}

.status-pill.warn,
.mini-pill.warn {
  color: var(--amber);
  background: #fff2d6;
  border-color: #efd39e;
}

.status-pill.fail,
.mini-pill.fail {
  color: var(--red);
  background: #fde8e8;
  border-color: #efb8b8;
}

.status-pill.neutral,
.mini-pill.neutral {
  color: var(--blue);
  background: #eaf1fb;
  border-color: #bdd0ef;
}

.preview-box {
  margin-top: 16px;
  background: #f1f6f4;
  border: 1px solid var(--line);
  padding: 12px;
}

.preview-box p {
  margin: 8px 0 0;
  color: #34423d;
  line-height: 1.5;
}

.timeline {
  display: grid;
  gap: 8px;
}

.system-control-panel {
  display: grid;
  gap: 14px;
}

.ai-specialist-card {
  border: 1px solid #bdd0ef;
  border-top: 4px solid var(--blue);
  background: #f4f8fe;
  padding: 12px;
}

.ai-specialist-card strong {
  display: block;
  margin: 8px 0 5px;
}

.ai-specialist-card p {
  margin: 0;
  color: #34423d;
  line-height: 1.5;
}

.timeline-entry {
  display: grid;
  grid-template-columns: 76px 1fr;
  gap: 10px;
  border-left: 3px solid var(--green);
  padding: 8px 10px;
  background: var(--surface-2);
}

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

.timeline-entry p {
  margin: 0;
  line-height: 1.4;
}

.recommendation-metric {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.recommendation-metric div {
  border: 1px solid #c8e3d6;
  background: white;
  padding: 12px;
}

.recommendation-metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-bottom: 3px;
}

.recommendation-metric strong {
  font-size: 20px;
}

.case-queue {
  display: grid;
  gap: 8px;
}

.queue-item {
  text-align: start;
  width: 100%;
}

.queue-item.active {
  border-color: var(--green);
  background: #eef8f2;
}

.queue-item strong,
.queue-item span,
.queue-item em {
  display: block;
}

.queue-item span,
.queue-item em {
  color: var(--muted);
  margin-top: 3px;
  font-size: 12px;
}

.queue-item em {
  color: var(--green);
  font-style: normal;
  font-weight: 800;
}

.source-block {
  border-color: #b8ddcb;
  background: #f3faf6;
}

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

.assessment-pack {
  border: 2px solid var(--green);
  background: #f6fbf8;
  padding: 14px;
}

.assessment-pack-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}

.assessment-pack-head h4 {
  margin: 3px 0 4px;
  font-size: 24px;
}

.assessment-pack-head p,
.assessment-authority-row p {
  margin: 0;
  color: #34423d;
  line-height: 1.45;
}

.assessment-pack-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.assessment-pack-cell,
.assessment-rule-row div {
  border: 1px solid #c8e3d6;
  background: white;
  padding: 10px;
  min-width: 0;
}

.assessment-pack-cell span,
.assessment-rule-row span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.assessment-pack-cell strong {
  display: block;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.assessment-pack-cell small {
  display: block;
  color: #34423d;
  font-weight: 800;
  margin-top: 4px;
  line-height: 1.35;
}

.assessment-rule-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.assessment-rule-row .mini-pill {
  justify-content: flex-start;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: start;
}

.assessment-escalation-row {
  border: 1px solid #efd39e;
  background: #fff9ec;
  margin-top: 8px;
  padding: 10px;
}

.assessment-escalation-row span {
  color: var(--amber);
  display: block;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 4px;
}

.assessment-escalation-row p {
  margin: 0;
  line-height: 1.45;
}

.assessment-authority-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid #c8e3d6;
  margin-top: 12px;
  padding-top: 12px;
}

.summary-block {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 12px;
}

.summary-block p {
  margin: 6px 0 0;
  line-height: 1.45;
}

.officer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 22, 19, 0.55);
  display: grid;
  place-items: center;
  padding: 18px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  width: min(680px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

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

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-weight: 900;
}

.approval-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.approval-challenge {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  background: #f3faf6;
  border: 1px solid #c8e3d6;
  padding: 12px;
  margin-bottom: 14px;
}

.qr-block {
  width: 112px;
  height: 112px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: white;
  border: 1px solid var(--line);
  padding: 8px;
}

.qr-block div {
  background: #13251f;
}

.qr-block div:nth-child(2n),
.qr-block div:nth-child(7),
.qr-block div:nth-child(13) {
  background: #dbe6e2;
}

.demo-code {
  display: block;
  font-size: 28px;
  letter-spacing: 0;
  margin: 4px 0;
}

.approval-challenge p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.error-text {
  color: var(--red);
  min-height: 22px;
  font-size: 13px;
  font-weight: 800;
}

.seal-card {
  border: 2px solid var(--green);
  background: #f3faf6;
  padding: 20px;
  margin-bottom: 14px;
  overflow: hidden;
}

.seal-card.empty {
  border-style: dashed;
  color: var(--muted);
  background: var(--surface-2);
}

.seal-title {
  font-weight: 900;
  font-size: 18px;
  margin-bottom: 14px;
}

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

.seal-field {
  min-width: 0;
  border: 1px solid #c8e3d6;
  background: rgba(255, 255, 255, 0.78);
  padding: 12px;
}

.seal-field .note-label {
  display: block;
  margin-bottom: 6px;
  color: var(--green-2);
}

.seal-field strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.verify-link {
  display: inline-flex;
  margin-top: 14px;
  color: var(--green-2);
  font-weight: 900;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.final-summary {
  line-height: 1.5;
}

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

.module-card {
  min-height: 180px;
}

.module-card h3 {
  margin-top: 14px;
}

.module-card p {
  color: var(--muted);
  line-height: 1.5;
}

.active-module {
  border-color: rgba(23, 107, 77, 0.55);
  background: #f3faf6;
}

.module-status {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.ar {
  direction: rtl;
  text-align: right;
  line-height: 1.6;
}

.inline-ar {
  display: inline;
  direction: rtl;
}

.form-alt {
  color: var(--muted);
  font-weight: 700;
  margin-top: -4px;
}

.brand-subtitle.ar,
.nav-item .ar {
  text-align: left;
  direction: rtl;
}

.nav-item .ar {
  color: var(--muted);
  font-size: 13px;
}

.nav-item.active .ar,
.nav-item:hover .ar {
  color: var(--green-2);
}

.panel h3.ar,
.section-head h2.ar,
.topbar h1.ar {
  margin-top: -5px;
  color: var(--green-2);
}

.metric-strip strong.ar,
.metric-strip span.ar {
  display: block;
  text-align: left;
}

body.office-auth-locked .main > :not(#officeAuthGate) {
  display: none !important;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

  .topbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-strip,
  .two-column,
  .three-column,
  .dashboard-grid,
  .module-grid,
  .assessment-pack-grid,
  .assessment-rule-row {
    grid-template-columns: 1fr;
    min-width: 0;
  }
}

@media (max-width: 700px) {
  .main,
  .sidebar {
    padding: 14px;
  }

  .form-grid,
  .document-controls,
  .approval-details,
  .approval-challenge,
  .seal-grid {
    grid-template-columns: 1fr;
  }

  .assessment-pack-head,
  .assessment-authority-row {
    align-items: stretch;
    flex-direction: column;
  }

  .nav-list {
    grid-template-columns: 1fr;
  }

  .office-auth-actions {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 22px;
  }
}
