/* WMI Operations and Costing — base styles.
   Brand: blue #15669E (actions, links), charcoal #37383A (headings).
   Logical properties (inline-start/end) keep the layout correct in RTL. */

:root {
  --brand-blue: #15669e;
  --brand-blue-dark: #0f4f7b;
  --brand-charcoal: #37383a;
  --text: #3c3c3c;
  --muted: #6b6d70;
  --border: #dfe3e8;
  --bg: #f5f7f9;
  --surface: #ffffff;
  --error-bg: #fdecec;
  --error-text: #9b1c1c;
  --info-bg: #eaf3fa;
  --radius: 6px;
  --font: "Segoe UI", "Noto Sans", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { color: var(--brand-charcoal); font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }

a { color: var(--brand-blue); }
a:hover { color: var(--brand-blue-dark); }

:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }

.muted { color: var(--muted); }
.lead { font-size: 1.1rem; color: var(--brand-charcoal); }

.skip-link {
  position: absolute;
  inset-inline-start: -9999px;
  top: 0;
  background: var(--surface);
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { inset-inline-start: 0.5rem; }

/* Buttons */
.btn {
  display: inline-block;
  font: inherit;
  border-radius: var(--radius);
  border: 1px solid transparent;
  padding: 0.45rem 1rem;
  cursor: pointer;
  text-decoration: none;
}
.btn--primary { background: var(--brand-blue); color: #fff; }
.btn--primary:hover { background: var(--brand-blue-dark); }
.btn--secondary { background: var(--surface); color: var(--brand-charcoal); border-color: var(--border); }
.btn--secondary:hover { border-color: var(--brand-blue); color: var(--brand-blue); }
.btn--link { background: none; color: var(--brand-blue); padding: 0.45rem 0.5rem; }
.btn--link:hover { text-decoration: underline; }
.btn--block { width: 100%; }

/* Alerts */
.alert { padding: 0.6rem 0.8rem; border-radius: var(--radius); margin: 0 0 1rem; }
.alert--error { background: var(--error-bg); color: var(--error-text); }
.alert--info { background: var(--info-bg); color: var(--brand-charcoal); }

/* Forms */
.form__field { display: block; margin-bottom: 1rem; }
.form__field > span { display: block; font-weight: 600; color: var(--brand-charcoal); margin-bottom: 0.3rem; }
.form input, .form select {
  width: 100%;
  font: inherit;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}
.form input:focus, .form select:focus { border-color: var(--brand-blue); }

/* Sign-in and error pages */
body.centered {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 4px solid var(--brand-blue);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: 0 2px 12px rgba(55, 56, 58, 0.08);
}
.auth-card__head { text-align: center; margin-bottom: 1rem; }
.auth-card__logo { height: 72px; width: auto; }
.auth-card__app { margin: 0.5rem 0 0; color: var(--muted); }
.auth-card h1 { text-align: center; }

.lang-switch { display: flex; justify-content: center; gap: 0.25rem; margin-bottom: 1rem; }
.lang-switch__option {
  padding: 0.2rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
}
.lang-switch__option.is-active { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }

/* Signed-in shell: light header, sidebar, content */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--surface);
  padding: 0.5rem 1.25rem;
  border-bottom: 3px solid transparent;
  border-image: linear-gradient(to right, var(--brand-blue), var(--brand-charcoal)) 1;
}
[dir="rtl"] .topbar { border-image: linear-gradient(to left, var(--brand-blue), var(--brand-charcoal)) 1; }
.topbar__brand { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.topbar__logo { height: 40px; width: auto; }
.topbar__app { color: var(--brand-charcoal); font-weight: 600; font-size: 1.05rem; }
.topbar__context { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.topbar__item { display: flex; flex-direction: column; line-height: 1.2; }
.topbar__label { font-size: 0.75rem; color: var(--muted); }
.topbar__value { color: var(--brand-charcoal); font-weight: 600; }
.topbar__form { margin: 0; }

.shell { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  padding: 1rem 0;
}
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar__link {
  display: block;
  padding: 0.55rem 1.25rem;
  color: var(--brand-charcoal);
  text-decoration: none;
  border-inline-start: 3px solid transparent;
}
.sidebar__link:hover { background: var(--bg); color: var(--brand-blue); }
.sidebar__link.is-active { border-inline-start-color: var(--brand-blue); color: var(--brand-blue); font-weight: 600; background: var(--info-bg); }

.content { flex: 1; padding: 1.5rem 2rem; min-width: 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  max-width: 720px;
}

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; border-inline-end: none; border-bottom: 1px solid var(--border); padding: 0.25rem 0; }
  .content { padding: 1rem; }
}

/* Slice 0.2: admin screens */
.center { text-align: center; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
.alert--success { background: #e8f5ec; color: #1d5e34; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.page-head h1 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; margin-bottom: 1rem; max-width: 980px; }
.grid .card { max-width: none; }
.card + .card { margin-top: 1rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.actions form { margin: 0; }
.btn--danger { background: var(--surface); color: var(--error-text); border-color: #e6b3b3; }
.btn--danger:hover { background: var(--error-bg); }
.form input:disabled { background: var(--bg); color: var(--muted); }
.form small { display: block; margin-top: 0.25rem; }

.table-wrap { overflow-x: auto; max-width: 980px; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table th, .table td { padding: 0.6rem 0.8rem; text-align: start; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { color: var(--brand-charcoal); font-weight: 600; background: var(--bg); font-size: 0.9rem; }
.table tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; background: var(--info-bg); color: var(--brand-charcoal); margin-inline-end: 0.25rem; }
.badge--green { background: #e8f5ec; color: #1d5e34; }
.badge--grey { background: #eceef1; color: var(--muted); }
.badge--red { background: var(--error-bg); color: var(--error-text); }

.checks { border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem 1rem; }
.checks legend { font-weight: 600; color: var(--brand-charcoal); padding: 0 0.25rem; }
.check { display: flex; align-items: center; gap: 0.5rem; padding: 0.25rem 0; }
.form .check input { width: auto; }

.secret { font-family: Consolas, "Courier New", monospace; font-size: 1.3rem; letter-spacing: 0.05em; background: var(--bg); border: 1px dashed var(--border); padding: 0.5rem 0.75rem; display: inline-block; direction: ltr; }

.topbar__small { font-size: 0.75rem; }

.choice-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 1rem 0; }
.choice { font: inherit; text-align: start; padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--brand-charcoal); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.choice:hover { border-color: var(--brand-blue); color: var(--brand-blue); }
.choice.is-current { border-color: var(--brand-blue); }
.grid .card + .card { margin-top: 0; }

/* Slice 0.3: approvals */
.small { font-size: 0.85rem; }
.badge--amber { background: #fff4e0; color: #8a5300; }
.form-inline { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.75rem; }
.form--row { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; margin-top: 0.75rem; }
.form--row .form__field { margin-bottom: 0; }
.form textarea { width: 100%; font: inherit; padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: var(--radius); }
.decision { display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 720px) { .decision { grid-template-columns: 1fr; } }
.table--compact th, .table--compact td { padding: 0.4rem 0.6rem; }
.table--plain th { background: none; width: 40%; }
.page-head h1 .muted { font-weight: 400; }

/* Slice 0.3: notifications, clarification, user details */
.bell { text-decoration: none; color: var(--brand-charcoal); font-size: 0.9rem; }
.bell__count { display: inline-block; min-width: 1.4rem; padding: 0 0.35rem; border-radius: 999px; background: var(--brand-blue); color: #fff; text-align: center; font-size: 0.8rem; }
.notice-list { list-style: none; padding: 0; margin: 0; max-width: 980px; }
.notice { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 0.5rem; }
.notice.is-unread { border-inline-start: 4px solid var(--brand-blue); }
.notice form { margin: 0; }
.notice__button { all: unset; box-sizing: border-box; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; width: 100%; padding: 0.7rem 1rem; }
.notice__button:focus-visible { outline: 2px solid var(--brand-blue); }
.notice.is-unread .notice__text { font-weight: 600; color: var(--brand-charcoal); }
.clarify { border-top: 1px solid var(--border); margin-top: 1rem; padding-top: 1rem; }
.clarify h3 { font-size: 1rem; margin: 0 0 0.5rem; color: var(--brand-charcoal); }
.phone { display: flex; gap: 0.5rem; }
.form .phone select { width: 9rem; flex-shrink: 0; }
.form__label { display: block; font-weight: 600; color: var(--brand-charcoal); margin-bottom: 0.3rem; }
.plain-list { margin: 0; padding-inline-start: 1.2rem; }
.card--wide { max-width: 980px; margin-bottom: 1rem; }

/* Slice 0.4: permission grid, settings, date picker */
.perm-grid tbody th { width: 34%; font-weight: 600; }
.perm-grid thead th { font-size: 0.85rem; }
.perm-grid td { vertical-align: middle; }
.perm-sensitive { margin: 0.75rem 0 0.25rem; display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.check--inline { display: inline-flex; margin-inline-end: 1rem; }

/* Date fields (static/js/datepicker.js): DD-MMM-YYYY in both languages. */
.form__field > span.date-field, .date-field {
  position: relative; display: flex; align-items: stretch; gap: 0.35rem;
  max-width: 14rem; font-weight: normal; margin: 0;
}
.date-field .date-input { flex: 1; min-width: 0; text-align: left; }
.date-field__button {
  flex: none; width: 2.4rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.date-field__button:hover, .date-field__button:focus { border-color: var(--brand-blue); }
.date-field__button:disabled { cursor: default; opacity: 0.5; }
.date-field__icon {
  width: 1rem; height: 0.9rem; border: 2px solid var(--brand-charcoal); border-top-width: 4px; border-radius: 2px;
}
.datepicker {
  position: absolute; top: calc(100% + 4px); inset-inline-start: 0; z-index: 20; width: 17rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); padding: 0.6rem;
}
.datepicker[hidden] { display: none; }
.datepicker__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.datepicker__title { font-weight: 600; color: var(--brand-charcoal); }
.datepicker__nav {
  font: inherit; font-size: 1.2rem; line-height: 1; width: 2rem; height: 2rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); cursor: pointer;
}
[dir="rtl"] .datepicker__nav { transform: scaleX(-1); }
.datepicker__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.datepicker__weekday { font-size: 0.75rem; color: var(--muted); padding: 0.2rem 0; }
.datepicker__day {
  font: inherit; font-size: 0.9rem; padding: 0.35rem 0; border: 1px solid transparent; border-radius: 4px;
  background: none; cursor: pointer; color: var(--text);
}
.datepicker__day:hover, .datepicker__day:focus { border-color: var(--brand-blue); outline: none; }
.datepicker__day.is-today { font-weight: 700; color: var(--brand-blue); }
.datepicker__day.is-selected { background: var(--brand-blue); color: #fff; }
.datepicker__foot { display: flex; gap: 0.4rem; justify-content: flex-end; margin-top: 0.5rem; }
.btn--small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }

/* Pricing settings */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.25rem; margin: 0 0 0.75rem; }
.facts dt { font-weight: 600; color: var(--brand-charcoal); }
.facts dd { margin: 0; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.table--form td { padding: 0.3rem 0.4rem; vertical-align: middle; }
.table--form input[type="text"], .table--form select {
  width: 100%; min-width: 6rem; font: inherit; padding: 0.35rem 0.45rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.form .input--short { max-width: 14rem; }
.form-row { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center; }
.form-row .form-inline { margin-top: 0; }
.card--wide + .card--wide { margin-top: 1rem; }

/* Slice 0.5: audit screen and attachments */
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: 0 1rem; align-items: end; }
.filters .form__field { margin-bottom: 0.75rem; }
.filters__buttons { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.audit td { font-size: 0.9rem; }
.nowrap { white-space: nowrap; }
.changes { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 0.15rem 0.6rem; }
.changes dt { color: var(--muted); }
.changes dd { margin: 0; overflow-wrap: anywhere; }
.changes__old { color: var(--error-text); text-decoration: line-through; }
.pager { display: flex; gap: 1rem; align-items: center; margin: 1rem 0; }
.version-row td { background: var(--bg); }
.upload-form { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: 0.75rem; max-width: 30rem; }
.upload-form h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.attachment-actions { align-items: flex-end; margin-top: 0.5rem; }
.form--inline-wide { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }
.form--inline-wide .form__field { margin-bottom: 0; }

/* Side menu: modules (two levels), collapsible; user menu in the header */
.sidebar { padding: 0.5rem 0; }
.module { border-bottom: 1px solid var(--border); }
.module:last-child { border-bottom: none; }
.module__title {
  list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  padding: 0.7rem 1rem 0.5rem 1.25rem; font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}
[dir="rtl"] .module__title { padding: 0.7rem 1.25rem 0.5rem 1rem; text-transform: none; letter-spacing: 0; font-size: 0.85rem; }
.module__title::-webkit-details-marker { display: none; }
.module__title::after { content: "+"; font-size: 1rem; font-weight: 400; }
.module[open] > .module__title::after { content: "−"; }
.module.is-active > .module__title { color: var(--brand-blue); }
.module__title:hover, .module__title:focus-visible { color: var(--brand-blue); }
.module ul { padding-bottom: 0.4rem; }
.sidebar__toggle { display: none; }

.user-menu { position: relative; }
.user-menu__summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0.5rem; border: 1px solid transparent; border-radius: var(--radius);
}
.user-menu__summary::-webkit-details-marker { display: none; }
.user-menu__summary:hover, .user-menu[open] > .user-menu__summary { border-color: var(--border); background: var(--bg); }
.user-menu__caret { width: 0; height: 0; border: 5px solid transparent; border-top-color: var(--brand-charcoal); margin-top: 5px; }
.user-menu__panel {
  position: absolute; inset-inline-end: 0; top: calc(100% + 4px); z-index: 30; min-width: 14rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12); padding: 0.35rem 0;
}
.user-menu__link {
  display: block; width: 100%; padding: 0.55rem 1rem; color: var(--brand-charcoal); text-decoration: none;
  text-align: start; background: none; border: 0; font: inherit; cursor: pointer;
}
.user-menu__link:hover, .user-menu__link:focus-visible { background: var(--bg); color: var(--brand-blue); }
.user-menu__form { margin: 0; border-top: 1px solid var(--border); margin-top: 0.35rem; padding-top: 0.35rem; }
.user-menu__signout { color: var(--error-text); }

@media (max-width: 720px) {
  .topbar { padding: 0.5rem 0.75rem; }
  .topbar__app { display: none; }
  .topbar__context { gap: 0.5rem; }
  .sidebar__toggle {
    display: block; width: calc(100% - 1.5rem); margin: 0.25rem 0.75rem; padding: 0.5rem 0.75rem; font: inherit;
    font-weight: 600; text-align: start; background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); cursor: pointer;
  }
  .sidebar.is-scripted .sidebar__modules { display: none; }
  .sidebar.is-scripted.is-open .sidebar__modules { display: block; }
}

/* Slice 0.7: notifications and email log */
.notice { display: flex; align-items: center; }
.notice__open { flex: 1; min-width: 0; }
.notice__read { padding-inline-end: 0.75rem; }
.btn--link.btn--small { padding: 0.2rem 0.4rem; }
.status-counts { display: flex; gap: 0.5rem; flex-wrap: wrap; margin: 0.5rem 0 1rem; }

/* Imports */
.import-templates { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.row--error td { background: var(--error-bg); }

/* Company screen tabs (slice 0.10) */
.tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; border-bottom: 2px solid var(--border, #d9dde3); margin: 0 0 1rem; }
.tabs__tab { padding: 0.55rem 1rem; text-decoration: none; color: inherit; border: 1px solid transparent; border-bottom: none;
  border-radius: 6px 6px 0 0; margin-bottom: -2px; }
.tabs__tab:hover { background: #f1f4f8; }
.tabs__tab--active { border-color: var(--border, #d9dde3); background: #fff; font-weight: 600; border-bottom: 2px solid #fff; }
.company-logo { max-height: 90px; max-width: 280px; display: block; margin: 0.5rem 0; }

/* Print layout of a company's documents */
body.print { background: #fff; }
.print-page { max-width: 210mm; margin: 0 auto; padding: 12mm; font-size: 11pt; }
.print-head { display: flex; gap: 1.25rem; align-items: flex-start; border-bottom: 2px solid #1f3864; padding-bottom: 0.75rem; }
.print-logo { max-height: 70px; max-width: 220px; }
.print-header { margin: 0.75rem 0; }
.print-body { min-height: 80mm; margin: 1rem 0; }
.print-bank { border-top: 1px solid #ccc; padding-top: 0.5rem; }
.print-foot { border-top: 1px solid #ccc; margin-top: 1rem; padding-top: 0.5rem; font-size: 9pt; color: #555; }
@media print { .print-page { padding: 0; } }
