/* Facilities Management - styles. Logical properties keep Arabic (RTL) and English (LTR) in sync. */

:root {
  --accent: #12302c;
  --accent-ink: #eef3f1;
  --accent-soft: #c9d6d2;
  --ground: #f2f4f3;
  --surface: #ffffff;
  --ink: #15211f;
  --ink-2: #33403d;
  --muted: #4c5a57;
  --line: #d9dfdd;
  --line-soft: #e4e9e7;
  --control: #aeb8b5;
  --link: #0f5a50;
  --danger: #a32019;

  --green-bg: #cdebd8;
  --green-ink: #0f4a2c;
  --green: #1e8e4e;
  --yellow-bg: #fbe7a1;
  --yellow-ink: #5a3e00;
  --yellow: #c99400;
  --red-bg: #f6cfca;
  --red-ink: #7a1a14;
  --red: #c62828;

  --sans: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --radius: 10px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
}
body.no-scroll {
  overflow: hidden;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.35;
  text-wrap: balance;
}
h2 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.4;
}
a {
  color: var(--link);
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}
.top :focus-visible {
  outline-color: var(--accent-ink);
}

.wrap {
  width: 100%;
  max-width: 1200px;
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 32px);
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 13px;
}
.strong {
  font-weight: 600;
}
.mono {
  font-family: var(--mono);
  font-size: 0.92em;
}
.nowrap {
  white-space: nowrap;
}
.icon {
  display: inline-flex;
  flex-shrink: 0;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.loading,
.empty {
  padding: 32px 20px;
  color: var(--muted);
  text-align: center;
}
.empty .btn {
  margin-top: 12px;
}

/* ------------------------------- header -------------------------------- */

.top {
  background: var(--accent);
  color: var(--accent-ink);
}
.top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding-block: 14px;
}
.top-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border: 1.5px solid currentColor;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}
.brand-name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
}
.brand-tag {
  font-size: 12.5px;
  line-height: 1.4;
  opacity: 0.82;
}

.lang {
  display: inline-flex;
  border: 1px solid var(--control);
  border-radius: 8px;
  overflow: hidden;
}
.lang-btn {
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  font-size: 14px;
  cursor: pointer;
}
.lang-btn[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}
.top .lang {
  border-color: rgba(238, 243, 241, 0.45);
}
.top .lang-btn[aria-pressed='true'] {
  background: var(--accent-ink);
  color: var(--accent);
}

.user-btn {
  min-height: 44px;
  padding: 4px 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: start;
  cursor: pointer;
}
.user-btn:hover {
  border-color: rgba(238, 243, 241, 0.45);
}
.user-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.user-name {
  font-size: 14px;
  font-weight: 600;
}
.user-role {
  font-size: 12px;
  color: var(--accent-soft);
}

.nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
}
.nav-link {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-bottom: 3px solid transparent;
  color: var(--accent-soft);
  font-size: 14.5px;
  text-decoration: none;
  white-space: nowrap;
}
.nav-link:hover {
  color: #ffffff;
}
.nav-link[aria-current='page'] {
  border-bottom-color: var(--accent-ink);
  color: #ffffff;
  font-weight: 600;
}

/* -------------------------------- page --------------------------------- */

.main {
  padding-block: 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  min-height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--control);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.btn:hover {
  border-color: var(--ink-2);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
}
.btn-danger {
  border-color: var(--danger);
  background: var(--danger);
  color: #ffffff;
  font-weight: 600;
}
.btn-small {
  padding: 0 12px;
  font-size: 14px;
}
.btn-icon {
  width: 44px;
  padding: 0;
}
.btn-block {
  width: 100%;
}
.btn-end {
  margin-inline-start: auto;
}

/* status colors: green, yellow, red, white */
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--control);
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: 16px;
}
.card {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  text-align: start;
  cursor: pointer;
}
.card-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.card-label .dot {
  width: 12px;
  height: 12px;
}
.card-num {
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 600;
  line-height: 1.1;
}
.card[aria-pressed='true'] {
  border-color: currentColor;
}
.card-valid,
.chip-valid {
  background: var(--green-bg);
  color: var(--green-ink);
}
.card-near,
.chip-near {
  background: var(--yellow-bg);
  color: var(--yellow-ink);
}
.card-expired,
.chip-expired {
  background: var(--red-bg);
  color: var(--red-ink);
}
.card-review,
.chip-review {
  background: var(--surface);
  color: #1d2a28;
}
.card-review {
  border-color: var(--control);
}
.card-review[aria-pressed='true'] {
  border-color: #1d2a28;
}
.chip-review {
  box-shadow: inset 0 0 0 1px #8c9996;
}
.card-valid .dot,
.chip-valid .dot {
  background: var(--green);
}
.card-near .dot,
.chip-near .dot {
  background: var(--yellow);
}
.card-expired .dot,
.chip-expired .dot {
  background: var(--red);
}
.card-review .dot,
.chip-review .dot {
  background: var(--surface);
  border: 2px solid #6b7775;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.chip .dot {
  width: 8px;
  height: 8px;
}
.note {
  font-size: 12.5px;
}
.note-near {
  color: var(--yellow-ink);
}
.note-expired {
  color: var(--red-ink);
}
.tag {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 4px;
  background: #e9edec;
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
}

/* panels and tables */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.panel.pad {
  padding: 20px 24px;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.panel-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.panel-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line-soft);
  text-align: center;
}
.inline-field {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--ink-2);
}
.table-scroll {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: start;
}
.files-table {
  min-width: 960px;
}
th {
  padding: 12px 20px;
  background: var(--ground);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  text-align: start;
  white-space: nowrap;
}
td {
  padding: 10px 20px;
  border-top: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
td.wrap-cell {
  white-space: normal;
  min-width: 180px;
}
.cell-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cell-stack > *,
.meta > * {
  align-self: flex-start;
}
.row-actions {
  display: flex;
  gap: 6px;
}

/* forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.hint {
  font-size: 12.5px;
  color: var(--muted);
}
input[type='text'],
input[type='email'],
input[type='password'],
input[type='number'],
input[type='date'],
input[type='search'],
input[type='url'],
input[type='file'],
select {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--control);
  border-radius: 8px;
  background: var(--surface);
  font-size: 15px;
}
.inline-field select {
  width: auto;
}
input:disabled,
select:disabled {
  background: var(--ground);
  color: var(--muted);
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.check input {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.span-2 {
  grid-column: 1 / -1;
}
.form-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--red-bg);
  color: var(--red-ink);
  font-size: 14px;
  font-weight: 500;
}
.settings {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 720px;
}

/* dialog */
.dialog {
  width: min(600px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  overflow-y: auto;
}
.dialog::backdrop {
  background: rgba(21, 33, 31, 0.55);
}
.dialog form {
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.dialog-title {
  font-size: 20px;
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toast {
  position: fixed;
  inset-block-end: 20px;
  inset-inline: 16px;
  z-index: 100;
  width: fit-content;
  max-width: calc(100vw - 32px);
  margin-inline: auto;
  padding: 12px 18px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-size: 14.5px;
}
.toast-bad {
  background: var(--danger);
}

/* sign in */
.auth {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.auth-card .lang {
  align-self: center;
}
.auth-brand {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--accent);
}

/* reader */
.doc-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 24px;
}
.doc-list {
  flex: 1 1 300px;
  min-width: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.doc-list-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.doc-search {
  position: relative;
  display: flex;
  align-items: center;
}
.doc-search .icon {
  position: absolute;
  inset-inline-start: 12px;
  color: var(--muted);
  pointer-events: none;
}
.doc-search .doc-search-input {
  width: 100%;
  padding-inline-start: 38px;
}
.doc-hit {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
}
.doc-hit-page {
  color: var(--accent);
  font-weight: 500;
}
.doc-hit-text {
  overflow-wrap: anywhere;
}
.doc-hit mark {
  background: #fdeaa8;
  color: var(--ink);
  border-radius: 3px;
  padding: 0 2px;
}
.doc-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}
.doc-list-head h2 {
  font-size: 15px;
}
.doc-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
  overflow-y: auto;
}
.doc-item {
  width: 100%;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  text-align: start;
  cursor: pointer;
}
.doc-item:hover {
  background: var(--ground);
}
.doc-item[aria-current='true'] {
  border-color: var(--accent);
  background: #e6eeeb;
}
.doc-item[aria-current='true'] .tag {
  background: var(--surface);
}
.doc-item-name {
  font-weight: 500;
  line-height: 1.45;
}
.doc-item[aria-current='true'] .doc-item-name {
  font-weight: 600;
}
.doc-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.doc {
  flex: 4 1 520px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.doc-head {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.doc-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: 16px 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
}
.meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.meta-label {
  font-size: 12.5px;
  color: var(--muted);
}
.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.meta .mono {
  font-weight: 600;
}

.pdf {
  display: flex;
  flex-direction: column;
  border: 1px solid #c9d1ce;
  border-radius: var(--radius);
  background: #dde3e0;
  overflow: hidden;
}
.pdf-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid #c9d1ce;
}
.pdf-group {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pdf-page {
  padding-inline: 8px;
  font-size: 14px;
  color: var(--ink-2);
  white-space: nowrap;
}
.pdf-zoom {
  min-width: 48px;
  text-align: center;
  color: var(--ink-2);
}
.pdf-stage {
  height: 72vh;
  min-height: 360px;
  padding: 16px;
  overflow: auto;
  text-align: center;
}
.pdf-canvas {
  display: inline-block;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(21, 33, 31, 0.18);
}
.pdf-msg {
  padding: 48px 16px;
  color: var(--ink-2);
}
.pdf-full {
  position: fixed;
  inset: 0;
  z-index: 50;
  border: 0;
  border-radius: 0;
}
.pdf-full .pdf-stage {
  flex: 1;
  height: auto;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .user-text {
    display: none;
  }
  .card-num {
    font-size: 36px;
  }
  th,
  td {
    padding-inline: 14px;
  }
  .pdf-page {
    padding-inline: 2px;
  }
}

@media print {
  .top,
  .actions,
  .row-actions,
  .toast {
    display: none !important;
  }
  body {
    background: #ffffff;
  }
}

/* Read acknowledgement */
.ack-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 14px 20px;
}
.ack-text {
  margin: 0;
  color: var(--muted);
}
.ack-ok {
  margin: 0;
  color: var(--green-ink);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.ack-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ack-count {
  font-family: var(--mono);
  font-size: 13px;
}
.ack-count.ack-full {
  color: var(--green-ink);
  font-weight: 600;
}
.ack-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  max-height: 40vh;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.ack-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.ack-list li:last-child {
  border-bottom: 0;
}
.ack-h {
  margin: 12px 0 6px;
  font-size: 14px;
}

/* ------------------------------- branding ------------------------------- */

/* The logo sits on a white tile so any logo colours read on the dark header. */
.brand-logo {
  flex-shrink: 0;
  height: 52px;
  max-width: 200px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border-radius: 8px;
}
.brand-logo img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.brand-text {
  min-width: 0;
}
.brand.has-logo .brand-name {
  overflow-wrap: anywhere;
}
/* Sign-in page: logo large and centred above the name. */
.brand-auth {
  flex-direction: column;
  text-align: center;
  gap: 14px;
}
.brand-auth.has-logo .brand-logo {
  height: auto;
  max-width: min(280px, 100%);
  padding: 0;
  background: none;
}
.brand-auth .brand-logo img {
  max-height: 104px;
}

/* Settings: logo preview and buttons */
.label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink-2);
}
.logo-preview {
  min-height: 120px;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--control);
  border-radius: 10px;
  background: var(--ground);
}
.logo-preview img {
  display: block;
  max-width: min(320px, 100%);
  max-height: 110px;
  object-fit: contain;
}
.logo-actions {
  justify-content: flex-start;
}
.field .logo-actions .btn-primary {
  font-size: 14.5px;
  color: #ffffff;
}
.btn.is-busy {
  opacity: 0.6;
  pointer-events: none;
}
.visually-hidden {
  position: absolute !important;
  inset-inline-start: 0;
  width: 1px !important;
  min-width: 0 !important;
  height: 1px !important;
  min-height: 0 !important;
  margin: -1px !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.logo-actions {
  position: relative;
}
.logo-actions label.btn:focus-within,
.visually-hidden:focus-visible + label.btn {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .top .brand-logo {
    height: 42px;
    max-width: 128px;
    padding: 4px 8px;
  }
  .top .brand {
    gap: 10px;
  }
  .top .brand-name {
    font-size: 15px;
  }
  .top .brand.has-logo .brand-tag {
    display: none;
  }
}
@media (max-width: 380px) {
  .top .brand-logo {
    max-width: 104px;
  }
}

/* Sign-in page links and notices */
.auth-link {
  margin: 0;
  text-align: center;
  font-size: 14px;
}
.auth-link a:not(.btn) {
  color: var(--link);
}
.notice {
  margin: 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--green-bg);
  color: var(--green-ink);
}
