/* ===== RTL MODE ENABLED ===== */
html {
  direction: rtl;
}
html, body {
  direction: rtl;
  text-align: right;
}
body {
  direction: rtl;
}

/* Logical properties helpers */
.mud-typography, .mud-table, .mud-nav-link, .mud-input, .mud-button-root {
  direction: rtl;
}

/* ===== شركة الشروق — Brand Identity (from logo) ===== */
:root {
  --brand-blue: #044CBE;
  --brand-blue-dark: #033A94;
  --brand-blue-soft: rgba(4, 76, 190, 0.12);
  --brand-black: #111111;
  --brand-black-2: #1A1A1A;
  --brand-gray: #5B6B78;
  --brand-line: #E2E5EA;
  --brand-surface: #FFFFFF;
  --brand-bg: #F4F6F9;
  --brand-success: #1B7A4E;
  --brand-warning: #C45C12;
  --brand-error: #C62828;
  --brand-info: #044CBE;
  --font-ui: 'Tajawal', sans-serif;
  --font-code: 'IBM Plex Mono', monospace;
}

html, body {
  font-family: var(--font-ui);
  background: var(--brand-bg);
  margin: 0;
  color: var(--brand-black);
}

/* Mud overrides */
.mud-layout { background: var(--brand-bg) !important; }
.mud-drawer { background: var(--brand-black) !important; color: #EDEFF1 !important; }
.mud-nav-link {
  color: #C7D0D8 !important;
  border-radius: 6px !important;
  margin: 1px 6px !important;
  min-height: 40px !important;
  gap: 10px !important;
}
.mud-nav-link .mud-nav-link-icon,
.mud-nav-link .mud-icon-root {
  color: #8FA3B5 !important;
  fill: #8FA3B5 !important;
  font-size: 1.25rem !important;
  min-width: 24px !important;
  opacity: 1 !important;
  display: inline-flex !important;
  visibility: visible !important;
}
.mud-nav-link.active,
.mud-nav-link:hover {
  background: var(--brand-blue-soft) !important;
  color: #fff !important;
}
.mud-nav-link.active .mud-nav-link-icon,
.mud-nav-link.active .mud-icon-root,
.mud-nav-link:hover .mud-nav-link-icon,
.mud-nav-link:hover .mud-icon-root {
  color: #6BA3F0 !important;
  fill: #6BA3F0 !important;
}
.mud-nav-link.active { border-inline-end: 2px solid var(--brand-blue); }
.app-nav .nav-section {
  color: #7A8B99 !important;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.mud-button-filled.mud-button-filled-primary {
  background: var(--brand-blue) !important;
}
.mud-button-filled.mud-button-filled-primary:hover {
  background: var(--brand-blue-dark) !important;
}

/* Brand chips */
.code-chip {
  font-family: var(--font-code);
  font-size: 11px;
  border: 1px solid var(--brand-line);
  border-bottom: 2px solid var(--brand-blue);
  border-radius: 3px;
  padding: 2px 7px;
  background: #fff;
  color: var(--brand-black);
}

/* Force LTR for serial codes, IDs, codes with slashes */
.force-ltr,
.force-ltr input,
.force-ltr .mud-input,
.force-ltr .mud-input-slot,
.force-ltr .mud-input-control-input-container {
  direction: ltr !important;
  text-align: left !important;
  unicode-bidi: isolate !important;
}

.contract-code-badge {
  direction: ltr !important;
  unicode-bidi: isolate !important;
  display: inline-block !important;
  font-family: var(--font-code), monospace !important;
  letter-spacing: 0.5px;
}

/* Stat / panel cards */
.brand-card {
  border: 1px solid var(--brand-line) !important;
  border-radius: 8px !important;
  background: var(--brand-surface);
}
.brand-card-blue { border-top: 3px solid var(--brand-blue) !important; }
.brand-card-black { border-top: 3px solid var(--brand-black) !important; }
.brand-card-success { border-top: 3px solid var(--brand-success) !important; }
.brand-card-warning { border-top: 3px solid var(--brand-warning) !important; }
.brand-card-error { border-top: 3px solid var(--brand-error) !important; }

.brand-panel-head {
  background: #F7F8FA;
  border-bottom: 1px solid var(--brand-line);
  padding: 12px 16px;
  font-weight: 700;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #F4F6F9 0%, #E8EEF8 50%, #F4F6F9 100%);
}
.login-page img { max-width: 180px; height: auto; }
.brand-logo { height: 40px; width: auto; object-fit: contain; }

/* Tables */
.mud-table { border: 1px solid var(--brand-line) !important; border-radius: 8px; overflow: hidden; }
.mud-table thead .mud-table-cell { background: #F7F8FA !important; color: var(--brand-gray) !important; font-weight: 600 !important; }

/* AppBar subtle brand line */
.mud-appbar { border-bottom: 1px solid var(--brand-line) !important; }

/* Drawer brand strip */
.drawer-brand {
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px;
}
.drawer-brand img,
.drawer-logo {
  height: 42px;
  width: auto;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 4px 6px;
}

/* Top bar company logo */
.topbar-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  margin-inline: 8px 4px;
}
@media (max-width: 600px) {
  .topbar-logo { height: 28px; }
}

/* ===== Fix MudBlazor outlined field labels (cut through border) — RTL ===== */
.mud-input-label.mud-input-label-inputcontrol,
.mud-input-label.mud-input-label-outlined {
  background-color: #fff !important;
  padding-inline: 6px !important;
  z-index: 2;
  line-height: 1.2 !important;
}

/* Outlined dense: keep label above the border cleanly */
.mud-input-control.mud-input-control-margin-dense {
  margin-top: 6px;
  margin-bottom: 6px;
}

.mud-input.mud-input-outlined .mud-input-outlined-border {
  border-color: var(--brand-line) !important;
}

.mud-input.mud-input-outlined:focus-within .mud-input-outlined-border,
.mud-input.mud-input-outlined.mud-input-focused .mud-input-outlined-border {
  border-color: var(--brand-blue) !important;
  border-width: 1.5px !important;
}

/* Ensure legend/label gap is visible so text isn't sliced by the border */
.mud-input.mud-input-outlined .mud-input-slot {
  min-height: 40px;
}

.mud-input-control .mud-input-label-outlined.mud-input-label-shrink {
  background: #fff !important;
  padding: 0 6px !important;
  transform-origin: top right !important;
}

/* Select same treatment */
.mud-select .mud-input-label-outlined,
.mud-select .mud-input-label {
  background-color: #fff !important;
  padding-inline: 6px !important;
}

/* Placeholder / empty label not overlapping border mid-line */
.mud-input > input.mud-input-root,
.mud-input > textarea.mud-input-root,
.mud-select .mud-input-slot {
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

.mud-input.mud-input-outlined.mud-input-adorned-start {
  padding-inline-start: 0;
}

/* Dialog form fields spacing */
.mud-dialog .mud-input-control {
  margin-bottom: 12px;
}

/* Prefer non-sliced labels: slightly larger notch via legend */
fieldset.mud-input-outlined-border legend {
  width: auto !important;
  max-width: 100%;
  padding: 0 4px;
  font-size: 0.75em;
  visibility: hidden;
  height: 0;
}

/* ===== AppBar / Main content offset ===== */
.mud-appbar {
  z-index: 1200 !important;
}
.mud-main-content {
  padding-top: 72px !important;
  min-height: 100vh;
}

/* ===== Dialog / Popup RTL fixes ===== */
.mud-dialog {
  border-radius: 12px !important;
  overflow: hidden;
  max-width: 100%;
}
.mud-dialog .mud-dialog-title {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 12px;
  padding: 16px 18px !important;
  border-bottom: 1px solid #E2E5EA;
  margin: 0 !important;
}
.mud-dialog .mud-dialog-title .mud-button-root,
.mud-dialog .mud-dialog-title .mud-icon-button {
  margin: 0 !important;
  order: -1; /* close button on the left in RTL visual flow */
  flex-shrink: 0;
}
.mud-dialog .mud-dialog-content {
  padding: 18px !important;
}
.mud-dialog .mud-dialog-actions {
  padding: 12px 18px 16px !important;
  border-top: 1px solid #E2E5EA;
  gap: 8px;
}
.mud-overlay {
  z-index: 1300 !important;
}
.mud-dialog-container {
  z-index: 1400 !important;
}

/* Keep header user block tidy */
.mud-appbar .mud-toolbar-appbar {
  gap: 8px;
}

/* ===== Compact sheet action icons ===== */
.sheet-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  vertical-align: middle;
}
.sheet-actions .mud-file-upload {
  display: inline-flex;
}
.sheet-actions .mud-icon-button {
  padding: 6px !important;
}

/* ===== Dialog: compact, centered, RTL-friendly ===== */
.mud-dialog {
  border-radius: 12px !important;
  margin: 16px !important;
  max-width: 96vw !important;
}
.mud-dialog-width-xs {
  max-width: min(360px, 94vw) !important;
  width: min(360px, 94vw) !important;
}
.mud-dialog-width-sm {
  max-width: min(480px, 94vw) !important;
  width: min(480px, 94vw) !important;
}
.mud-dialog-width-md {
  max-width: min(640px, 94vw) !important;
  width: min(640px, 94vw) !important;
}
.mud-dialog-width-lg {
  max-width: min(800px, 96vw) !important;
  width: min(800px, 96vw) !important;
}
.mud-dialog-width-xl {
  max-width: min(960px, 96vw) !important;
  width: min(960px, 96vw) !important;
}
.mud-dialog .mud-dialog-title {
  display: flex !important;
  flex-direction: row-reverse !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 8px;
  padding: 14px 16px !important;
  border-bottom: 1px solid #E2E5EA;
  text-align: right;
}
.mud-dialog .mud-dialog-title .mud-typography {
  flex: 1;
  text-align: right;
}
.mud-dialog .mud-dialog-title .mud-button-root,
.mud-dialog .mud-dialog-title .mud-icon-button {
  order: 0;
  margin: 0 !important;
  flex-shrink: 0;
}
.mud-dialog .mud-dialog-content {
  padding: 16px !important;
  text-align: right;
}
.mud-dialog .mud-dialog-actions {
  padding: 12px 16px 14px !important;
  border-top: 1px solid #E2E5EA;
  justify-content: flex-start !important; /* start = right in RTL */
  flex-direction: row-reverse;
  gap: 8px;
}
.mud-dialog .mud-input-control {
  margin-bottom: 12px;
}
.mud-dialog-container {
  align-items: center !important;
  justify-content: center !important;
  padding: 16px !important;
}

/* ===== Dialog RTL FINAL ===== */
html[dir="rtl"] .mud-dialog,
[dir="rtl"] .mud-dialog,
.mud-dialog {
  direction: rtl !important;
  text-align: right !important;
}

.mud-dialog-title,
.mud-dialog .mud-dialog-title {
  direction: rtl !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  text-align: right !important;
  padding: 14px 16px !important;
  border-bottom: 1px solid #E2E5EA !important;
  gap: 8px;
}

/* Title text on the right; close (X) on the left */
.mud-dialog-title .mud-typography {
  order: 2;
  flex: 1;
  text-align: right !important;
  margin: 0 !important;
}
.mud-dialog-title .mud-button-root,
.mud-dialog-title .mud-icon-button,
.mud-dialog-title button {
  order: 1 !important;
  margin-inline-end: 0 !important;
  margin-inline-start: 0 !important;
}

.mud-dialog-content {
  direction: rtl !important;
  text-align: right !important;
  padding: 16px !important;
}

/* All inputs inside dialog: RTL */
.mud-dialog .mud-input-control,
.mud-dialog .mud-input,
.mud-dialog .mud-select {
  direction: rtl !important;
  text-align: right !important;
}

.mud-dialog .mud-input input,
.mud-dialog .mud-input textarea,
.mud-dialog .mud-select .mud-input-slot {
  text-align: right !important;
  direction: rtl !important;
}

/* Numeric field: keep number LTR but field chrome RTL — arrows on the LEFT in RTL */
.mud-dialog .mud-input-numeric-spin {
  direction: ltr;
}
.mud-dialog .mud-input.mud-input-adorned-end {
  flex-direction: row-reverse !important;
}
.mud-dialog input[type="number"] {
  text-align: right !important;
  direction: rtl !important;
}

/* Labels */
.mud-dialog .mud-input-label {
  right: auto !important;
  left: auto !important;
  transform-origin: top right !important;
  text-align: right !important;
}

/* Actions RTL: first DOM item sits on the right (حفظ) */
.mud-dialog-actions {
  direction: rtl !important;
  display: flex !important;
  flex-direction: row !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  padding: 12px 16px 14px !important;
  border-top: 1px solid #E2E5EA !important;
}

/* Global form fields RTL outside dialogs too */
.mud-input-control {
  direction: rtl;
}
.mud-input input,
.mud-select .mud-input-slot {
  text-align: right;
}

/* ===== Dialog fields: label above input (reliable RTL) ===== */
.dlg-field {
  margin-bottom: 14px;
  direction: rtl;
  text-align: right;
}
.dlg-field > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #5B6B78;
  margin-bottom: 6px;
  text-align: right;
}
.dlg-field .mud-input-control {
  margin: 0 !important;
}
.dlg-field .mud-input input,
.dlg-field .mud-select .mud-input-slot {
  text-align: right !important;
  direction: rtl !important;
}

/* Title row: X left, title right */
.mud-dialog .mud-dialog-title {
  direction: rtl !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px;
  flex-direction: row-reverse !important;
}
.mud-dialog .mud-dialog-title > .mud-typography,
.mud-dialog .mud-dialog-title > div {
  flex: 1;
  text-align: right !important;
}
.mud-dialog .mud-dialog-title .mud-icon-button,
.mud-dialog .mud-dialog-title .mud-button-root {
  flex: 0 0 auto;
  margin: 0 !important;
}

/* Hide empty floating labels when we use external labels */
.dlg-field .mud-input-label {
  display: none !important;
}

/* ===== Dialog close X LEFT ===== */
.mud-dialog .mud-dialog-title {
  display: flex !important;
  flex-direction: row !important; /* DOM: [title][X] or [X][title] */
  align-items: center !important;
  justify-content: space-between !important;
  direction: ltr !important; /* force X physical left / title physical right */
  padding: 14px 16px !important;
  border-bottom: 1px solid #E2E5EA !important;
  gap: 8px !important;
}

/* Title text always on the right */
.mud-dialog .mud-dialog-title .mud-typography,
.mud-dialog .mud-dialog-title > div:not(.mud-button-root) {
  order: 2 !important;
  flex: 1 1 auto !important;
  text-align: right !important;
  direction: rtl !important;
  margin: 0 !important;
}

/* Close button always on the left */
.mud-dialog .mud-dialog-title .mud-icon-button,
.mud-dialog .mud-dialog-title .mud-button-root,
.mud-dialog .mud-dialog-title button {
  order: 1 !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  margin-inline: 0 !important;
}

/* Content & actions stay RTL */
.mud-dialog .mud-dialog-content,
.mud-dialog .mud-dialog-actions {
  direction: rtl !important;
}

/* ===== Explicit dialog title: X LEFT | title RIGHT ===== */
.dlg-title-bar {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  width: 100% !important;
  direction: ltr !important; /* physical: first item = left */
  gap: 8px;
}
.dlg-close-btn {
  order: 1 !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  color: #5B6B78 !important;
}
.dlg-title-text {
  order: 2 !important;
  flex: 1 1 auto !important;
  text-align: right !important;
  direction: rtl !important;
  font-weight: 700 !important;
  margin: 0 !important;
}

/* Override any Mud default title layout when our bar is present */
.mud-dialog-title:has(.dlg-title-bar) {
  padding: 8px 12px !important;
  display: block !important;
}
.mud-dialog-title:has(.dlg-title-bar) > .mud-icon-button {
  display: none !important; /* hide any residual Mud close */
}

/* ===== Sidebar responsive (fix + mobile hide) ===== */
.mud-drawer.app-drawer {
  z-index: 1300 !important;
}
.mud-overlay {
  z-index: 1250 !important;
}

/* دع MudBlazor يدير الإخفاء/aria-hidden — لا نجبر transform يخالف حالته */
.mud-drawer-temporary:not(.mud-drawer-open) {
  pointer-events: none;
}
.mud-overlay {
  z-index: 1250 !important;
}
.menu-toggle {
  display: inline-flex !important;
  cursor: pointer !important;
  z-index: 1301 !important;
}

.mud-drawer-content {
  border-inline-start: 1px solid rgba(255,255,255,.06);
}

.menu-toggle {
  display: inline-flex !important;
  z-index: 1301;
}

/* ===== Modern Worker Card ===== */
.worker-card-header {
  background: linear-gradient(135deg, #1A1A1C 0%, #0F1A2E 55%, #044CBE 140%);
  color: #fff;
  border-radius: 14px !important;
  border: none !important;
}
.worker-card-header .code-chip {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-color: rgba(255,255,255,.25);
  border-bottom-color: #6BA3F0;
}
.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed #EFEFEF;
  font-size: 13px;
}
.kv-row span { color: #5B6B78; }
.kv-row b { font-weight: 700; text-align: left; }

@media print {
  .mud-drawer, .mud-appbar, .mud-button-root { display: none !important; }
  .mud-main-content { padding: 0 !important; margin: 0 !important; }
}

/* ===== QR Scan Interface ===== */
.qr-scan-panel {
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #E2E5EA;
  background: #fff;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.qr-scan-visual {
  background: linear-gradient(145deg, #1A1A1C 0%, #0F1A2E 50%, #044CBE 130%);
  padding: 28px 20px 24px;
  text-align: center;
  color: #fff;
}
.qr-frame {
  width: 140px;
  height: 140px;
  margin: 0 auto;
  position: relative;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.06);
  border-radius: 12px;
}
.qr-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid #6BA3F0;
}
.qr-corner.tl { top: 8px; left: 8px; border-right: none; border-bottom: none; border-radius: 6px 0 0 0; }
.qr-corner.tr { top: 8px; right: 8px; border-left: none; border-bottom: none; border-radius: 0 6px 0 0; }
.qr-corner.bl { bottom: 8px; left: 8px; border-right: none; border-top: none; border-radius: 0 0 0 6px; }
.qr-corner.br { bottom: 8px; right: 8px; border-left: none; border-top: none; border-radius: 0 0 6px 0; }
.qr-scan-form {
  padding: 18px 16px 20px;
  direction: rtl;
  text-align: right;
}
.qr-input input {
  font-family: 'IBM Plex Mono', monospace !important;
  letter-spacing: .02em;
}
.qr-result {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}
.qr-result.ok {
  background: rgba(27,122,74,.1);
  color: #1B7A4A;
}
.qr-result.err {
  background: rgba(192,57,43,.1);
  color: #C0392B;
}

/* ===== Printable Worker ID Card ===== */
.print-id-card {
  background: linear-gradient(145deg, #1A1A1C 0%, #0F1A2E 55%, #044CBE 140%);
  color: #fff;
  border-radius: 14px;
  padding: 18px;
  direction: rtl;
}
.print-id-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.print-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
}
.print-brand { font-weight: 800; font-size: 14px; }
.print-sub { font-size: 10px; opacity: .75; font-family: 'IBM Plex Mono', monospace; }
.print-status {
  margin-inline-start: auto;
  background: rgba(255,255,255,.15);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.print-id-name { font-size: 20px; font-weight: 800; }
.print-id-role { opacity: .85; font-size: 13px; margin: 4px 0 12px; }
.print-id-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.print-id-grid div {
  background: rgba(255,255,255,.1);
  border-radius: 8px;
  padding: 8px 10px;
}
.print-id-grid span { display: block; font-size: 10px; opacity: .7; }
.print-id-grid b { font-size: 12px; font-family: 'IBM Plex Mono', monospace; }
.print-id-qr {
  background: #fff;
  color: #1A1A1C;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  gap: 14px;
  align-items: center;
}
.print-id-qr img { border-radius: 6px; flex-shrink: 0; }
.print-scan-hint { font-weight: 700; font-size: 12px; margin-bottom: 4px; }
.print-id-qr code {
  font-size: 10px;
  word-break: break-all;
  color: #044CBE;
  display: block;
}
.print-issued { font-size: 10px; color: #5B6B78; margin-top: 6px; }

@media print {
  #printIdCard, #printIdCard * { visibility: visible !important; }
  #printIdCard {
    position: absolute;
    left: 0; top: 0;
    width: 100%;
    max-width: 420px;
    box-shadow: none;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .mud-drawer, .mud-appbar { display: none !important; }
}

/* ===== Dedicated QR Card Print Page ===== */
.print-page {
  min-height: 100vh;
  background: #F4F6F9;
  padding: 24px;
  direction: rtl;
  font-family: 'Tajawal', sans-serif;
}
.print-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.print-toolbar .btn-print {
  background: #044CBE;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  font-size: 14px;
}
.print-toolbar .btn-back {
  color: #5B6B78;
  text-decoration: none;
  font-size: 13px;
}
.print-toolbar .hint {
  margin-inline-start: auto;
  font-size: 12px;
  color: #5B6B78;
}

.id-card {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}
.id-card-inner {
  background: linear-gradient(145deg, #1A1A1C 0%, #0F1A2E 50%, #044CBE 130%);
  color: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
.id-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.id-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
}
.id-company { font-weight: 800; font-size: 15px; }
.id-sys { font-size: 10px; opacity: .75; font-family: 'IBM Plex Mono', monospace; }
.id-badge {
  margin-inline-start: auto;
  background: rgba(255,255,255,.15);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.id-name { font-size: 22px; font-weight: 800; line-height: 1.3; }
.id-meta { opacity: .85; font-size: 13px; margin: 4px 0 12px; }
.id-body {
  display: flex;
  gap: 14px;
  align-items: stretch;
}
.id-info { flex: 1; min-width: 0; }
.id-rows { display: flex; flex-direction: column; gap: 6px; }
.id-row {
  background: rgba(255,255,255,.1);
  border-radius: 8px;
  padding: 7px 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.id-row span { opacity: .7; }
.id-row b { font-family: 'IBM Plex Mono', monospace; font-weight: 600; }
.id-qr-box {
  background: #fff;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  color: #1A1A1C;
  flex-shrink: 0;
}
.id-qr-box img { display: block; border-radius: 4px; }
.id-qr-label { font-size: 11px; font-weight: 700; margin-top: 6px; color: #044CBE; }
.id-footer {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.15);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 10px;
  opacity: .8;
  flex-wrap: wrap;
}
.id-token {
  font-family: 'IBM Plex Mono', monospace;
  word-break: break-all;
  max-width: 60%;
  text-align: left;
  direction: ltr;
}

@media print {
  .no-print { display: none !important; }
  .print-page {
    background: #fff !important;
    padding: 0 !important;
    min-height: auto !important;
  }
  .id-card {
    max-width: 85.6mm;
    margin: 0;
  }
  .id-card-inner {
    box-shadow: none !important;
    border-radius: 0 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  @page {
    size: 85.6mm 54mm;
    margin: 0;
  }
}

/* Local SVG QR and card photo */
.id-qr-box svg{display:block;width:150px;height:150px;margin:0 auto;border-radius:4px}
.id-avatar{width:54px;height:54px;flex:0 0 54px;border-radius:12px;background:#fff;color:#044CBE;display:flex;align-items:center;justify-content:center;overflow:hidden;font-size:24px;font-weight:800}
.id-avatar img{width:100%;height:100%;object-fit:cover}
.id-body{align-items:center}
.print-toolbar-bottom{margin-top:20px;margin-bottom:0}
@media print{
  .id-qr-box svg{width:150px !important;height:150px !important}
}


/* ===== UX: sticky action bar (Sarky & forms) ===== */
.sarky-action-bar {
  position: sticky;
  bottom: 0;
  z-index: 20;
  background: #fff;
  border: 1px solid #E2E5EA;
  border-radius: 12px 12px 0 0;
  padding: 12px 16px;
  margin-top: 12px;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
}
@media (max-width: 640px) {
  .sarky-action-bar {
    flex-direction: column;
    align-items: stretch !important;
  }
  .sarky-action-bar .mud-button {
    width: 100%;
  }
}


/* ===== Mobile UX enhancements ===== */
html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

/* Touch-friendly targets */
@media (max-width: 960px) {
  .mud-button-root {
    min-height: 40px;
  }
  .mud-input-control {
    margin-top: 4px !important;
  }
  .mud-table-root .mud-table-cell {
    padding: 10px 8px !important;
  }
  /* Page content breathing room */
  .mud-main-content {
    padding-inline: 12px !important;
    padding-bottom: 88px !important; /* space for sticky bars */
  }
}

/* Horizontal scroll wrappers for wide tables */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
}
.table-scroll table {
  min-width: 720px;
}

/* Card-style table rows on very small screens when using mud breakpoint */
@media (max-width: 600px) {
  .mud-table.mud-table-small .mud-table-cell:before {
    font-weight: 600;
    color: #5B6B78;
  }
  /* Stack header actions */
  .page-actions-mobile {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100%;
  }
  .page-actions-mobile > * {
    width: 100%;
  }
  /* Chips row wrap */
  .mud-chip {
    max-width: 100%;
  }
  /* Filters stack */
  .filters-bar {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .filters-bar .mud-input-control,
  .filters-bar .mud-select {
    width: 100% !important;
    min-width: 0 !important;
  }
}

/* Sarky lines: card layout on mobile */
@media (max-width: 768px) {
  .sarky-lines-desktop { display: none !important; }
  .sarky-lines-mobile { display: block !important; }
  .sarky-line-card {
    border: 1px solid #E2E5EA;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    background: #fff;
  }
  .sarky-line-card .line-title {
    font-weight: 700;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
  }
}
@media (min-width: 769px) {
  .sarky-lines-desktop { display: block !important; }
  .sarky-lines-mobile { display: none !important; }
}

/* Sticky mobile bottom safe area */
.sarky-action-bar {
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
@media (max-width: 640px) {
  .sarky-action-bar {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    border-radius: 12px 12px 0 0;
    margin-inline: -4px;
  }
}

/* Prevent iOS zoom on inputs */
@media (max-width: 960px) {
  input.mud-input-slot,
  .mud-input input,
  .mud-select input {
    font-size: 16px !important;
  }
}

/* Code chips don't overflow */
.code-chip {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}


/* ===== Settlement stages responsive ===== */
.settlement-stages {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.settlement-stage {
  flex: 1 0 auto;
  min-width: 72px;
  text-align: center;
}
.settlement-stage-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid #DCD7CB;
}
.settlement-stage-label {
  font-size: 10px;
  margin-top: 4px;
  line-height: 1.3;
  color: #5B6B78;
}
.settlement-stage.is-current .settlement-stage-label {
  color: #044CBE;
}
@media (max-width: 640px) {
  .settlement-stages {
    flex-direction: column;
    flex-wrap: wrap;
    gap: 8px;
  }
  .settlement-stage {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-width: 0;
    width: 100%;
    text-align: start;
  }
  .settlement-stage-dot {
    margin: 0;
    flex-shrink: 0;
  }
  .settlement-stage-label {
    margin-top: 0;
    font-size: 12px;
  }
  .page-header-mobile {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .page-header-mobile .mud-stack {
    justify-content: flex-start !important;
  }
}

/* ===== Filter fields full width on mobile ===== */
.filter-field {
  min-width: 140px;
}
@media (max-width: 640px) {
  .filter-field {
    min-width: 0 !important;
    width: 100% !important;
    flex: 1 1 100%;
  }
  .filters-bar {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .filters-bar > * {
    width: 100% !important;
    max-width: 100% !important;
  }
}


/* ===== Empty state ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 16px;
  text-align: center;
}
.empty-state .mud-icon-root {
  opacity: 0.85;
  margin-bottom: 4px;
}


/* Dialog grid: prevent field overlap */
.mud-dialog .mud-grid {
  width: 100%;
  margin: 0 !important;
}
.mud-dialog .mud-grid-item {
  min-width: 0;
  overflow: hidden;
}
.mud-dialog .mud-input-adornment-text {
  white-space: nowrap;
  font-size: 0.75rem;
  max-width: 4rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mud-dialog .mud-input-helper-text {
  font-size: 0.7rem;
}


/* ===== CLEAN LAYOUT (all screens) ===== */
.app-drawer {
  background: #111111 !important;
}
.drawer-brand {
  padding: 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.drawer-brand-text { color: #fff; }
.app-nav .nav-section {
  color: #7A8B99 !important;
  font-weight: 600;
}
.mud-nav-link {
  color: #C7D0D8 !important;
  border-radius: 6px !important;
  margin: 1px 6px !important;
  min-height: 40px !important;
}
.mud-nav-link .mud-icon-root {
  color: #8FA3B5 !important;
  opacity: 1 !important;
}
.mud-nav-link.active,
.mud-nav-link:hover {
  background: rgba(4, 76, 190, 0.18) !important;
  color: #fff !important;
}
.mud-nav-link.active .mud-icon-root,
.mud-nav-link:hover .mud-icon-root {
  color: #6BA3F0 !important;
}
.page-shell {
  max-width: 100%;
  box-sizing: border-box;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
}
@media print {
  .mud-drawer, .mud-appbar, .no-print {
    display: none !important;
  }
  .mud-main-content {
    margin: 0 !important;
    padding: 0 !important;
  }
}




/* Drawer right side — open state only forced to right */
.mud-drawer.app-drawer {
  background: #111111 !important;
}
.mud-drawer-anchor-right.app-drawer {
  right: 0 !important;
  left: auto !important;
}
.mud-drawer.app-drawer .mud-nav-link { color: #C7D0D8 !important; }
.mud-drawer.app-drawer .mud-nav-link:hover,
.mud-drawer.app-drawer .mud-nav-link.active {
  background: rgba(4,76,190,.2) !important;
  color: #fff !important;
}
.mud-drawer.app-drawer .mud-nav-link .mud-icon-root { color: #8FA3B5 !important; }

/* ===== New Pages Responsive ===== */
.report-table { font-size: 12px; }
.report-header { margin-bottom: 16px; }
.report-title { font-size: 16px; font-weight: 700; }
.report-sub { font-size: 11px; color: #5B6B78; }

@media (max-width: 960px) {
  .page-header-mobile { flex-direction: column !important; align-items: flex-start !important; }
  .page-header-mobile .mud-stack-row { width: 100%; }
  .report-table td, .report-table th { padding: 6px 4px !important; font-size: 11px !important; }
  .filters-bar { flex-direction: column; }
  .filters-bar .filter-field { width: 100% !important; }
}

@media (max-width: 640px) {
  .report-table { display: block; overflow-x: auto; white-space: nowrap; }
  .report-table td, .report-table th { padding: 4px 3px !important; font-size: 10px !important; }
  .quick-actions { grid-template-columns: 1fr !important; }
  .stat-card { padding: 10px !important; }
  .stat-icon { width: 36px !important; height: 36px !important; }
  .stat-value { font-size: 18px !important; }
  .chart-card { padding: 12px !important; }
  .donut-chart { width: 140px !important; height: 140px !important; }
}

/* ===== Comprehensive Mobile Responsiveness ===== */
@media (max-width: 960px) {
  .mud-main-content .pa-4 { padding: 12px !important; }
  .mud-main-content .pa-md-6 { padding: 12px !important; }
  .mud-table .mud-table-cell { padding: 6px 8px !important; }
  .mud-dialog { margin: 8px !important; max-width: calc(100vw - 16px) !important; }
  .mud-grid-spacing-xs-2 > .mud-grid-item { padding: 4px !important; }
}
@media (max-width: 640px) {
  .mud-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .mud-table .mud-table-row { display: table-row; }
  .mud-table .mud-table-cell { display: table-cell; font-size: 11px !important; padding: 4px 3px !important; white-space: nowrap; }
  .mud-button-group { flex-wrap: wrap; }
  .mud-button-group .mud-button-root { flex: 1 1 auto; min-width: 80px; font-size: 11px !important; padding: 4px 8px !important; }
  .mud-grid .mud-grid-item { padding: 2px 0 !important; }
  .mud-select, .mud-text-field { width: 100% !important; }
  .mud-dialog-container { padding: 4px !important; }
  .mud-dialog-title { padding: 12px 16px !important; font-size: 14px !important; }
  .mud-dialog-content { padding: 8px 12px !important; }
  .mud-chip { font-size: 10px !important; height: 22px !important; padding: 0 6px !important; }
  .mud-tabs .mud-tab { padding: 6px 10px !important; min-width: auto !important; font-size: 11px !important; }
  .mud-tab-panel { padding: 8px !important; }
  .mud-snackbar { left: 8px !important; right: 8px !important; bottom: 8px !important; }
  .mud-table-pagination { flex-wrap: wrap; gap: 4px; }
  .workers-type-tabs .mud-button-root { font-size: 10px !important; padding: 4px 6px !important; }
  .qr-scan-panel { flex-direction: column !important; }
  .qr-scan-visual { min-height: 160px !important; padding: 16px !important; }
  .qr-frame { width: 100px !important; height: 100px !important; }
  .mud-drawer-responsive.mud-drawer-overlay { z-index: 1300; }
  .mud-navmenu .mud-navlink { padding: 8px 16px !important; }
}

/* Workers page specific mobile */
@media (max-width: 640px) {
  .workers-table .mud-table-cell[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 600;
    color: #5B6B78;
    display: inline;
  }
  .workers-table .mud-table-cell {
    display: block !important;
    width: 100% !important;
    text-align: right !important;
    padding: 4px 8px !important;
    white-space: normal !important;
  }
  .workers-table .mud-table-row {
    display: block !important;
    border-bottom: 1px solid #E2E5EA !important;
    margin-bottom: 8px !important;
    padding: 8px !important;
    background: #fff !important;
    border-radius: 8px !important;
  }
  .workers-table .mud-table-head { display: none !important; }
}

/* Contractors page mobile */
@media (max-width: 640px) {
  .mud-dialog .mud-grid .mud-grid-item {
    max-width: 100% !important;
    flex: 0 0 100% !important;
  }
}

/* Settlement review mobile */
@media (max-width: 640px) {
  .settlement-stages { gap: 6px !important; }
  .settlement-stage-dot { width: 24px !important; height: 24px !important; font-size: 10px !important; }
  .settlement-stage-label { font-size: 9px !important; }
}

/* QR Scanner mobile */
@media (max-width: 640px) {
  .qr-scan-panel { flex-direction: column !important; }
  .qr-scan-visual { min-height: 160px !important; padding: 16px !important; }
  .qr-frame { width: 100px !important; height: 100px !important; }
}

/* Tabs mobile */
@media (max-width: 640px) {
  .mud-tabs .mud-tab { padding: 6px 10px !important; min-width: auto !important; font-size: 11px !important; }
  .mud-tab-panel { padding: 8px !important; }
}

/* Pagination mobile */
/* ===== Popover & Picker Z-Index Fix (Prevent Drawer Overlap) ===== */
.mud-popover-provider,
.mud-popover,
.mud-popover-open,
.mud-picker-inline-paper,
.mud-popover-cascading-value,
.mud-paper.mud-popover-paper {
  z-index: 3500 !important;
}

/* ===== Popover width constraint (RTL fix) ===== */
/* MudBlazor popovers can overflow in RTL; cap their width */
.mud-popover.mud-popover-open {
  max-width: min(500px, 92vw) !important;
}

/* Dropdown list max height so it doesn't overflow off-screen */
.mud-popover .mud-list,
.mud-popover-cascading-value .mud-list {
  max-height: 260px !important;
  overflow-y: auto !important;
}

/* ===== Dialog Responsive (all screen sizes) ===== */
.mud-dialog {
  max-width: min(800px, 96vw) !important;
  width: min(760px, 96vw) !important;
}
.mud-dialog-content {
  max-height: 72vh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
}

@media (max-width: 600px) {
  .mud-dialog {
    width: 98vw !important;
    max-width: 98vw !important;
    margin: 8px auto !important;
  }
  .mud-dialog-content {
    max-height: 65vh !important;
    padding: 8px !important;
  }
  /* Stack grid columns on mobile */
  .mud-dialog .mud-grid-item {
    flex-basis: 100% !important;
    max-width: 100% !important;
  }
}
