/* Components used by the screens: stat tiles, board, cards, forms, dialogs, toasts, sign-in.
   Logical properties only, so Arabic (rtl) and English (ltr) share every rule. */

[hidden] {
  display: none !important;
}
.visually-hidden {
  position: absolute;
  inset-inline-start: 0; /* pinned, so its place in a table cell cannot widen the page */
  top: 0;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.small {
  font-size: 12.5px;
}

/* ---- inputs (SPEC section 7: Field) ---- */
input[type='text'],
input[type='search'],
input[type='date'],
select,
textarea {
  width: 100%;
  min-height: var(--control-md);
  padding: 9px var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  color: var(--ink);
  font: inherit;
}
textarea {
  resize: vertical;
}
input[aria-invalid='true'],
select[aria-invalid='true'],
textarea[aria-invalid='true'] {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}
input[type='checkbox'],
input[type='radio'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.req {
  color: var(--danger-ink);
}
.err {
  margin: 0;
  color: var(--danger-ink);
  font-size: 12.5px;
  font-weight: 500;
}
.err:empty {
  display: none;
}

/* ---- extra button styles (SPEC section 7: Button) ---- */
.btn.small {
  min-height: var(--control-sm);
  padding: 0 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}
.btn.danger {
  background: var(--surface-card);
  border-color: var(--danger-border);
  color: var(--danger-ink);
}
.link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}
.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-round);
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

/* ---- header user ---- */
.user-pill {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 4px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
/* Sign out sits inside the rounded user pill, so it takes the same rounded shape. */
.user-pill .btn {
  border-radius: var(--radius-pill);
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}
.user-pill .btn:hover {
  background: var(--surface-sunken);
  border-color: var(--border-control);
}
.count-badge {
  display: inline-block;
  margin-inline-start: 8px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--danger-ink);
  color: #fff;
  font: 600 11px/18px var(--font-mono);
}

/* ---- stat tiles (SPEC section 7: KPI tile) ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  display: grid;
  gap: 8px;
  padding: 16px;
  text-align: start;
  font: inherit;
  color: var(--ink);
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: none;
  cursor: pointer;
}
.stat:hover {
  border-color: var(--accent);
}
.stat[aria-pressed='true'] {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.stat .lbl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stat .lbl {
  font-size: 12.5px;
  color: var(--ink-muted);
}
.stat .tile-icon {
  flex: none;
  color: var(--ink-muted);
}
.stat .num {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 32px;
  font-weight: 600;
  color: var(--ink);
}

/* ---- toolbar ---- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.toolbar input[type='search'] {
  flex: 1;
  min-width: 220px;
  width: auto;
}
.toolbar select {
  width: auto;
  min-width: 190px;
}
.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--control-md);
  font-weight: 500;
  color: var(--ink);
}

/* ---- board filters: a button with a count, a panel that opens under the toolbar, and the
   active filters as removable tags ---- */
.filter-btn {
  gap: var(--space-2);
}
.filter-btn .tile-icon {
  color: var(--ink-muted);
}
.filter-btn[aria-expanded='true'],
.filter-btn.has-filters {
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-color: var(--accent);
}
.filter-btn[aria-expanded='true'] .tile-icon,
.filter-btn.has-filters .tile-icon {
  color: var(--accent);
}
.filter-badge {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11.5px;
  text-align: center;
}
.filter-badge[hidden] {
  display: none;
}
.filter-panel {
  display: grid;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding: var(--space-5);
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  animation: filter-panel-in 0.2s ease;
}
.filter-panel[hidden] {
  display: none;
}
@keyframes filter-panel-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}
.filter-pair {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.filter-pair > input {
  flex: 1;
  min-width: 0;
}
.filter-grid .field {
  grid-template-columns: minmax(0, 1fr);
}
/* Date created takes its own row: the choice, then the date box(es) on the same line. */
.filter-date {
  grid-column: 1 / -1;
}
.filter-date-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.filter-date-row > select {
  flex: 0 1 260px;
  min-width: 200px;
}
.filter-dates {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}
.filter-dates[hidden] {
  display: none;
}
.filter-dates input[type='date'] {
  width: 180px;
}
.filter-inline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
}
.filter-checks {
  align-content: end;
}
.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}
.filter-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.filter-tags:empty {
  display: none;
}
.filter-count {
  margin-inline-end: var(--space-2);
  font-size: 13px;
  color: var(--ink-muted);
}
.filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0;
  padding-inline: 12px 6px;
  font: 600 12.5px var(--font-body);
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.filter-tag:hover {
  border-color: var(--accent);
}
.filter-tag-x {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-round);
  font-size: 15px;
  line-height: 1;
  transition: background-color 0.15s ease;
}
.filter-tag:hover .filter-tag-x {
  background: var(--accent-soft-border);
}
@media (prefers-reduced-motion: reduce) {
  .filter-panel {
    animation: none;
  }
}

/* ---- board: a clean status bar (one tab per status, with a count) filters one list of cards,
   instead of showing every status side by side as kanban columns. ---- */
.chips {
  display: flex;
  gap: 4px;
  width: fit-content;
  max-width: 100%;
  margin-bottom: var(--space-4);
  padding: 5px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  scrollbar-width: none;
  position: relative;
  isolation: isolate;
}
.chips::-webkit-scrollbar {
  display: none;
}
/* Two highlights behind the buttons: one follows the mouse, one marks the chosen status.
   board.js sets their position and width; CSS makes them glide. */
.chip-hover,
.chip-indicator {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  width: 0;
  z-index: -1;
  border-radius: var(--radius-md);
  pointer-events: none;
  transition:
    transform 0.4s cubic-bezier(0.34, 1.4, 0.64, 1),
    width 0.4s cubic-bezier(0.34, 1.4, 0.64, 1),
    opacity 0.2s ease;
}
.chip-hover {
  background: var(--surface-muted);
  opacity: 0;
  transition-duration: 0.28s, 0.28s, 0.2s;
}
.chips.hovering .chip-hover {
  opacity: 1;
}
.chip-indicator {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.chip {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--control-md);
  padding: 0 12px;
  font: 600 13px var(--font-body);
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color 0.18s ease,
    color 0.18s ease,
    transform 0.18s ease;
}
.chip:hover {
  color: var(--ink);
}
.chip:active {
  transform: scale(0.95);
}
.chip[aria-pressed='true'] {
  color: var(--accent-ink);
}
.chip:hover .chip-dot {
  transform: scale(1.4);
}
@media (prefers-reduced-motion: reduce) {
  .chip,
  .chip-dot,
  .chip-count,
  .chip-hover,
  .chip-indicator {
    transition: none;
  }
}
.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-round);
  background: var(--border-control);
  transition: transform 0.18s ease;
}
.chip[aria-pressed='true'] .chip-dot {
  transform: scale(1.25);
}
.chip[data-status='returned'] .chip-dot {
  background: var(--danger-ink);
}
.chip[data-status='submitted'] .chip-dot {
  background: var(--accent);
}
.chip[data-status='bank_created'] .chip-dot,
.chip[data-status='approving'] .chip-dot {
  background: var(--warning-ink);
}
.chip[data-status='ready'] .chip-dot {
  background: var(--success-ink);
}
.chip[data-status='transferred'] .chip-dot {
  background: var(--ink);
}
.chip-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  color: var(--ink-2);
  font-size: 11.5px;
  text-align: center;
  transition:
    background-color 0.18s ease,
    color 0.18s ease;
}
.chip[aria-pressed='true'] .chip-count {
  background: var(--accent);
  color: var(--on-accent);
}
.board-list {
  display: grid;
  gap: var(--space-3);
}
.col-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}
.col-empty,
.col-note {
  margin: 0;
  padding: 12px 6px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink-muted);
  font-size: 12.5px;
  text-align: center;
}
.col-note {
  border-style: solid;
  border-color: transparent;
  padding: 2px;
}

/* A request card: name + status, amount, one line of context, then a grey footer with the
   reference and the requester. The top edge carries the status colour. On hover it lifts,
   tilts a little towards the mouse and a soft light follows the pointer (board.js sets
   --mx/--my/--rx/--ry). */
.card {
  --card-tone: var(--border-strong);
  position: relative;
  display: grid;
  gap: 6px;
  padding: 14px 16px 0;
  overflow: hidden;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-top: 3px solid var(--card-tone);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(22, 24, 29, 0.04);
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg))
    translateY(var(--lift, 0px));
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease,
    border-color 0.2s ease;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(
    260px circle at var(--mx, 50%) var(--my, 0%),
    rgba(10, 110, 148, 0.09),
    transparent 65%
  );
  opacity: 0;
  transition: opacity 0.25s ease;
}
.card:hover,
.card:focus-visible {
  --lift: -4px;
  border-color: var(--accent-soft-border);
  border-top-color: var(--card-tone);
  box-shadow:
    0 14px 28px rgba(22, 24, 29, 0.12),
    0 3px 8px rgba(22, 24, 29, 0.06);
}
.card:hover::before {
  opacity: 1;
}
.card:active {
  --lift: -1px;
}
.card[data-status='returned'] {
  --card-tone: var(--danger-ink);
}
.card[data-status='submitted'] {
  --card-tone: var(--accent);
}
.card[data-status='bank_created'],
.card[data-status='approving'] {
  --card-tone: var(--warning-ink);
}
.card[data-status='ready'] {
  --card-tone: var(--success-ink);
}
.card[data-status='transferred'] {
  --card-tone: var(--ink);
}
.card.stalled {
  border-inline-start: 4px solid var(--danger-ink);
}
.card.returned {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  border-top-color: var(--card-tone);
}
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}
.card-ben {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}
.card-amt {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.2;
  color: var(--ink);
}
.card-amt .mono {
  font-weight: 600;
}
.card-cur {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}
.card-ctx {
  font-size: 12.5px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 6px -16px 0;
  padding: 9px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-sunken);
  font-size: 12px;
  color: var(--ink-muted);
}
.card.returned .card-foot {
  background: transparent;
  border-top-color: var(--danger-border);
}
.card-ref {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--ink-muted);
}
.card-who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.card-top .card-pills {
  flex: none;
  justify-content: flex-end;
  max-width: 55%;
  margin-top: 0;
}
@media (prefers-reduced-motion: reduce) {
  .card {
    transform: none;
    transition: none;
  }
}

/* ---- states ---- */
.panel.state {
  justify-items: start;
}
.panel.state.error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}
.skeleton {
  background: var(--surface-muted);
  border-radius: var(--radius-sm);
}
.stat.skeleton {
  height: 78px;
  border: 0;
}
.skeleton.line {
  height: 14px;
  width: 60%;
}
.skeleton.card-skel {
  height: 96px;
  background: var(--surface-sunken);
}
@media (prefers-reduced-motion: no-preference) {
  .skeleton {
    animation: pulse 1.4s ease-in-out infinite;
  }
}
@keyframes pulse {
  50% {
    opacity: 0.55;
  }
}

/* ---- dialogs (shadows are allowed here, per SPEC section 6) ---- */
dialog.modal {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  color: var(--ink);
  box-shadow: var(--shadow-raised);
  overflow-y: auto;
}
dialog.modal.wide {
  width: min(700px, calc(100vw - 24px));
}
dialog.modal::backdrop {
  background: rgba(22, 24, 29, 0.5);
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 8px;
}
.modal-head h2 {
  font-size: 20px;
}
.modal-head .eyebrow {
  margin-bottom: 2px;
}
.modal-body {
  display: grid;
  gap: 14px;
  padding: 8px 24px 24px;
}
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

/* ---- request tracker: a summary card, then six connected steps. Across on a wide dialog,
   a vertical timeline when there isn't room (container query). Every state is also a word. ---- */
.tracker-btn {
  gap: 10px;
  border-color: var(--accent);
  color: var(--accent-ink);
}
.tracker-btn:hover {
  background: var(--accent-soft);
}
.tracker-btn-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.tracker-btn-dots span {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-round);
  background: var(--success-ink);
}
.tracker-btn-dots span:nth-child(2) {
  background: var(--accent);
  animation: tracker-blink 1.6s ease-in-out infinite;
}
.tracker-btn-dots span:nth-child(3) {
  background: var(--border-control);
}
@keyframes tracker-blink {
  50% {
    transform: scale(1.35);
  }
}

dialog.modal.tracker-dialog {
  width: min(1000px, calc(100vw - 24px));
}
.tracker {
  container-type: inline-size;
  display: grid;
  gap: var(--space-6);
}
.tracker-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.tracker-summary[data-tone='ok'] {
  border-color: var(--success-bg);
  background: var(--success-bg);
  color: var(--success-ink);
}
.tracker-summary[data-tone='bad'] {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-ink);
}
.tracker-summary[data-tone='warn'] {
  border-color: var(--warning-panel-border);
  background: var(--warning-panel);
  color: var(--warning-panel-ink);
}
.tracker-summary[data-tone='mute'] {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--ink-2);
}
.tracker-headline {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.tracker-now {
  font: 600 18px/24px var(--font-display);
}
.tracker-sub {
  font-size: 13px;
}
.tracker-progress {
  display: grid;
  gap: 6px;
  flex: 0 1 260px;
  min-width: 180px;
}
.tracker-progress-text {
  font-size: 12px;
  font-weight: 600;
}
.tracker-bar {
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-card);
}
.tracker-bar > span {
  display: block;
  width: var(--p);
  height: 100%;
  border-radius: inherit;
  background: currentColor;
  animation: tracker-fill 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) 0.2s both;
}
@keyframes tracker-fill {
  from {
    width: 0;
  }
}

.wf {
  --node: 52px;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin: 0;
  padding: 0;
  list-style: none;
}
.wf-step {
  --link: var(--border);
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 12px;
  padding-inline: 6px;
  text-align: center;
  animation: wf-in 0.45s ease both;
  animation-delay: calc(var(--i) * 80ms);
}
@keyframes wf-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}
/* the line to the next step, and its arrow head */
.wf-step:not(:last-child)::before,
.wf-step:not(:last-child)::after {
  content: '';
  position: absolute;
}
.wf-step:not(:last-child)::before {
  top: calc(var(--node) / 2 - 1.5px);
  inset-inline-start: calc(50% + var(--node) / 2 + 8px);
  width: calc(100% - var(--node) - 16px);
  height: 3px;
  border-radius: 3px;
  background: var(--link);
}
.wf-step:not(:last-child)::after {
  top: calc(var(--node) / 2 - 5px);
  inset-inline-start: calc(150% - var(--node) / 2 - 16px);
  width: 9px;
  height: 10px;
  background: var(--link);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}
html[dir='rtl'] .wf-step:not(:last-child)::after {
  transform: scaleX(-1);
}
.wf-step[data-link='done'] {
  --link: var(--success-ink);
}
.wf-step[data-link='bad'] {
  --link: var(--danger-border);
}
.wf-step[data-link='flow'] {
  --link: var(--accent);
}
/* into the current step the line "flows" */
.wf-step[data-link='flow']:not(:last-child)::before {
  background: repeating-linear-gradient(90deg, var(--accent) 0 10px, transparent 10px 16px);
  background-size: 16px 100%;
  animation: wf-flow 0.7s linear infinite;
}
html[dir='rtl'] .wf-step[data-link='flow']:not(:last-child)::before {
  animation-direction: reverse;
}
@keyframes wf-flow {
  to {
    background-position-x: 16px;
  }
}

.wf-node {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--node);
  height: var(--node);
  border: 2px solid var(--border-control);
  border-radius: var(--radius-round);
  background: var(--surface-card);
  color: var(--ink-muted);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}
.wf-node .tile-icon {
  width: 22px;
  height: 22px;
}
.wf-step:hover .wf-node {
  transform: translateY(-3px);
  box-shadow: 0 8px 18px rgba(22, 24, 29, 0.12);
}
.wf-step[data-state='done'] .wf-node {
  border-color: var(--success-ink);
  background: var(--success-bg);
  color: var(--success-ink);
}
.wf-step[data-state='done'] .wf-node .tile-icon {
  stroke-width: 2.4;
  animation: wf-pop 0.4s ease both;
  animation-delay: calc(var(--i) * 80ms + 0.25s);
}
@keyframes wf-pop {
  from {
    transform: scale(0.4);
    opacity: 0;
  }
}
.wf-step[data-state='current'] .wf-node {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  animation: wf-pulse 1.8s ease-out infinite;
}
@keyframes wf-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(10, 110, 148, 0.45);
  }
  70%,
  100% {
    box-shadow: 0 0 0 14px rgba(10, 110, 148, 0);
  }
}
.wf-step[data-state='rejected'] .wf-node {
  border-color: var(--danger-ink);
  background: var(--danger-bg);
  color: var(--danger-ink);
}
.wf-step[data-state='stopped'] .wf-node {
  border-color: var(--ink-2);
  background: var(--surface-muted);
  color: var(--ink-2);
}
.wf-step[data-state='attention'] .wf-node {
  border-color: var(--warning-ink);
  background: var(--warning-bg);
  color: var(--warning-ink);
}
.wf-step[data-state='attention'] .wf-node .tile-icon {
  stroke-width: 2.6;
}
.wf-step[data-state='waiting'] .wf-node {
  border-style: dashed;
}

.wf-text {
  display: grid;
  justify-items: center;
  gap: 4px;
  min-width: 0;
}
.wf-title {
  font: 600 14px/1.3 var(--font-display);
  color: var(--ink);
}
.wf-step[data-state='waiting'] .wf-title {
  color: var(--ink-2);
}
.wf-role {
  font-size: 12px;
  color: var(--ink-muted);
}
.wf-state {
  margin-top: 2px;
  padding: 3px 10px;
  border-radius: var(--radius-xs);
  background: var(--surface-muted);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}
.wf-step[data-state='done'] .wf-state {
  background: var(--success-bg);
  color: var(--success-ink);
}
.wf-step[data-state='current'] .wf-state {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.wf-step[data-state='rejected'] .wf-state {
  background: var(--danger-bg);
  color: var(--danger-ink);
}
.wf-step[data-state='attention'] .wf-state {
  background: var(--warning-bg);
  color: var(--warning-ink);
}
.wf-who {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}
.wf-when {
  font-size: 12px;
  color: var(--ink-muted);
}

/* not enough room for six across: a vertical timeline, arrows pointing down */
@container (max-width: 720px) {
  .wf {
    grid-template-columns: minmax(0, 1fr);
  }
  .wf-step {
    grid-template-columns: var(--node) minmax(0, 1fr);
    justify-items: start;
    column-gap: 14px;
    padding: 0 0 26px;
    text-align: start;
  }
  .wf-text {
    justify-items: start;
    padding-top: 4px;
  }
  .wf-step:not(:last-child)::before {
    top: calc(var(--node) + 6px);
    inset-inline-start: calc(var(--node) / 2 - 1.5px);
    width: 3px;
    height: calc(100% - var(--node) - 12px);
  }
  .wf-step:not(:last-child)::after,
  html[dir='rtl'] .wf-step:not(:last-child)::after {
    top: calc(100% - 14px);
    inset-inline-start: calc(var(--node) / 2 - 5px);
    width: 10px;
    height: 9px;
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    transform: none;
  }
  .wf-step[data-link='flow']:not(:last-child)::before {
    background: repeating-linear-gradient(180deg, var(--accent) 0 10px, transparent 10px 16px);
    background-size: 100% 16px;
    animation-name: wf-flow-down;
  }
  html[dir='rtl'] .wf-step[data-link='flow']:not(:last-child)::before {
    animation-direction: normal;
  }
}
@keyframes wf-flow-down {
  to {
    background-position-y: 16px;
  }
}

/* ---- request form (SPEC section 7: Field, section 8: Uploads) ---- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 14px;
}
.form-grid .full {
  grid-column: 1 / -1;
}
.form-section {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px 14px;
  grid-template-columns: 1fr 1fr;
  margin: 0;
  padding: var(--space-4);
  border: 1px solid var(--border-strong);
  border-bottom-width: 4px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface-card) 0%, var(--surface-sunken) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(22, 24, 29, 0.06),
    0 10px 20px rgba(22, 24, 29, 0.1),
    0 22px 36px rgba(22, 24, 29, 0.07);
}
/* No hover effect: a form section is not clickable, so it stays still under the mouse. */
.form-section-title {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.field {
  display: grid;
  gap: 4px;
  align-content: start;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.lbl {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.readonly {
  padding: 9px var(--space-3);
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
  font-weight: 600;
}
.hint {
  font-weight: 400;
  color: var(--ink-muted);
}
.radios {
  display: flex;
  gap: 18px;
  min-height: var(--control-md);
  align-items: center;
}
.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--ink);
}
.tier:empty {
  display: none;
}
.tier {
  margin: 0;
  padding: 8px var(--space-3);
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
}
.drop-wrap {
  position: relative;
}
.drop {
  display: block;
  padding: 16px;
  text-align: center;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  color: var(--ink-muted);
  font-weight: 500;
  cursor: pointer;
}
.drop:hover,
.drop.over,
.drop-wrap:focus-within .drop {
  border-color: var(--accent);
}
.files {
  display: grid;
  gap: 6px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}
.files li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-soft-border);
  border-radius: var(--radius-md);
  font-size: 13px;
}
.file-name {
  flex: 1;
  overflow-wrap: anywhere;
}
.sz {
  color: var(--ink-muted);
  font-size: 12px;
}
.form-error {
  margin: 0;
  padding: 8px var(--space-3);
  background: var(--danger-bg);
  color: var(--danger-ink);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
}

/* ---- toast ---- */
#toast-wrap {
  position: fixed;
  inset-inline: 0;
  bottom: 20px;
  z-index: 1000;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  box-shadow: var(--shadow-raised);
}
.toast.error {
  background: var(--danger-ink);
}

/* ---- sign-in (development) ---- */
.signin {
  display: grid;
  place-items: start center;
  padding: 32px 16px;
}
.signin-card {
  width: min(560px, 100%);
  gap: 12px;
}
.signin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.signin-sub {
  margin-top: 6px;
  font-size: 16px;
  color: var(--ink-muted);
}
.people {
  display: grid;
  gap: 8px;
  margin: 6px 0;
  padding: 0;
  list-style: none;
}
.person {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 52px;
  padding: 8px 14px;
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  font: inherit;
  color: var(--ink);
  text-align: start;
  cursor: pointer;
}
.person:hover {
  border-color: var(--accent);
}
.person-name {
  font-weight: 600;
}
.person-roles {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ---- request page ---- */
.detail {
  display: grid;
  gap: 14px;
  max-width: 860px;
  margin-inline: auto;
}
.back {
  justify-self: start;
}
.detail-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface-card);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.detail-head h2 {
  color: var(--ink);
  font-size: 22px;
}
.detail-head .card-ref {
  color: var(--ink-muted);
}
.detail-amt {
  margin: 4px 0 8px;
  font-size: 18px;
  font-weight: 600;
}
.stamp {
  flex: none;
  display: grid;
  place-items: center;
  width: 84px;
  height: 84px;
  padding: 6px;
  border: 2.5px solid var(--accent);
  outline: 1px dashed var(--accent);
  outline-offset: -6px;
  border-radius: var(--radius-round);
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
}
.stamp.green {
  border-color: var(--success-ink);
  outline-color: var(--success-ink);
  background: var(--success-bg);
  color: var(--success-ink);
}
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13.5px;
}
.banner.bad {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border: 1px solid var(--danger-border);
}
.banner.mute {
  background: var(--surface-muted);
  color: var(--ink-2);
  border: 1px solid var(--border);
}
/* "needs your action" notices (SPEC section 7: Notice, action-needed variant) */
.banner.action {
  background: var(--warning-panel);
  color: var(--warning-panel-ink);
  border: 1px solid var(--warning-panel-border);
}
.actions-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.panel h3 {
  font-size: 15px;
}
.kvs {
  display: grid;
  gap: 0;
  margin: 0;
}
.kv {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13.5px;
}
.kv:last-child {
  border-bottom: 0;
}
.kv dt {
  flex: none;
  color: var(--ink-muted);
}
.kv dd {
  margin: 0;
  font-weight: 600;
  text-align: end;
  overflow-wrap: anywhere;
}
ul.plain {
  margin: 0;
  padding-inline-start: 18px;
}
.files .file-name {
  text-align: start;
}

/* approval steps */
.timeline {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 10px;
}
.dot {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-radius: var(--radius-round);
  background: var(--surface-card);
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 700;
}
.dot.ok {
  background: var(--success-ink);
  border-color: var(--success-ink);
  color: #fff;
}
.dot.no {
  background: var(--danger-ink);
  border-color: var(--danger-ink);
  color: #fff;
}
.dot.wait {
  border-color: var(--warning-ink);
  color: var(--warning-ink);
}
.dot.lock {
  border-style: dashed;
}
.step-name {
  font-size: 14px;
}
.stage-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.note-input {
  flex: 1;
  min-width: 160px;
  width: auto;
}
.earlier {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}
.earlier summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
}
.earlier-round {
  margin-top: 8px;
}
.history {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.history li {
  display: grid;
  gap: 2px;
  padding-inline-start: 10px;
  border-inline-start: 2px solid var(--border);
  font-size: 13px;
}

/* my approvals */
.queue {
  display: grid;
  gap: 14px;
  max-width: 860px;
  margin-inline: auto;
}
.queue-count {
  font-weight: 600;
  color: var(--ink-muted);
}
.queue-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

/* bank-side status */
.bank-split {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.bank-list {
  display: grid;
  gap: 8px;
}
.bank-row {
  display: grid;
  gap: 4px;
  min-height: var(--control-md);
  padding: 10px 12px;
  text-align: start;
  font: inherit;
  color: var(--ink);
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: none;
  cursor: pointer;
}
.bank-row:hover {
  border-color: var(--accent);
}
.bank-row.selected {
  border: 2px solid var(--accent);
  padding: 9px 11px;
}
.bank-row > .mono {
  justify-self: start;
}
.bank-row-name {
  font-weight: 600;
}
.queue-item h2,
.bank-editor h2,
.admin-page h2 {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
}
.bank-editor h3 {
  margin: 18px 0 6px;
  font-size: 14px;
  color: var(--ink-2);
}
.bank-editor {
  display: grid;
  gap: 12px;
}
.bank-field {
  margin: 0;
  padding: 0;
  border: 0;
}
.bank-field legend {
  margin-bottom: 6px;
  padding: 0;
  font-weight: 600;
}
.bank-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}
.bank-choices.stacked {
  flex-direction: column;
}
@media (max-width: 900px) {
  .bank-split {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* admin */
.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.subtab {
  min-height: var(--control-md);
  padding: 0 16px;
  font: inherit;
  font-weight: 600;
  color: var(--ink-2);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
}
.subtab[aria-selected='true'] {
  color: var(--on-accent);
  background: var(--accent);
  border-color: var(--accent);
}
.table-wrap {
  overflow-x: auto;
  padding: 0;
}
/* Admin > Audit log */
.audit {
  display: grid;
  gap: 12px;
}
.audit-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.audit-filters input[type='search'] {
  flex: 1 1 260px;
}
.audit-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-muted);
}
.audit-table td {
  vertical-align: top;
}
.audit-table .nowrap {
  white-space: nowrap;
}
table.grid {
  width: 100%;
  border-collapse: collapse;
}
table.grid th,
table.grid td {
  padding: 10px 14px;
  text-align: start;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle);
}
table.grid th {
  font-size: 11px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--surface-page);
}
html[lang='ar'] table.grid th {
  letter-spacing: 0;
  text-transform: none;
}
table.grid tr.inactive td {
  color: var(--ink-muted);
}
table.grid input,
table.grid select {
  width: 100%;
  min-width: 120px;
}
.admin-settings {
  display: grid;
  gap: 12px;
  max-width: 520px;
}
.admin-settings input,
table.grid input,
table.grid select {
  min-height: var(--control-md);
  padding: 0 12px;
  font: inherit;
  color: var(--ink);
  background: var(--surface-card);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
}
.admin-settings input:disabled,
table.grid input:disabled {
  color: var(--ink-muted);
  background: var(--surface-page);
}
.panel > .btn {
  justify-self: start;
}
.visually-hidden {
  position: absolute;
  inset-inline-start: 0; /* pinned, so its place in a table cell cannot widen the page */
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* file preview */
.preview-img {
  display: block;
  max-width: 100%;
  max-height: 60vh;
  margin-inline: auto;
  border-radius: var(--radius-sm);
}
.preview-frame {
  width: 100%;
  height: 60vh;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
}
input[type='file'] {
  max-width: 100%;
  font: inherit;
}

/* ---- printed summary of a request: just the page, black on white ---- */
@media print {
  body {
    background: #fff;
  }
  .masthead,
  .entity-stripe,
  .site-footer,
  .tabs,
  .back,
  .actions-bar,
  .banner button,
  .stage-actions,
  .detail button,
  .detail .link,
  #toast-wrap {
    display: none !important;
  }
  .app {
    max-width: none;
    padding: 0;
  }
  .panel {
    break-inside: avoid;
    box-shadow: none;
    border-color: #999;
  }
  .detail-head h2 {
    margin-top: 0;
  }
}

@media (max-width: 900px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .form-grid,
  .form-section {
    grid-template-columns: 1fr;
  }
  .toolbar select,
  .toolbar .btn {
    width: 100%;
  }
  /* on a phone the date choice and each date box get a full line */
  .filter-date-row > select,
  .filter-dates,
  .filter-inline {
    flex: 1 1 100%;
  }
  .filter-dates input[type='date'] {
    flex: 1;
    width: auto;
    min-width: 0;
  }
  /* the four tiles become one strip you can swipe, so the list starts higher up */
  .stats {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    overflow-x: auto;
  }
  .stat {
    flex: 0 0 132px;
    padding: 8px 12px;
  }
  .stat .num {
    font-size: 20px;
  }
  .stat .lbl {
    font-size: 12px;
    line-height: 1.3;
  }
  /* Request page: whatever this person has to do comes first */
  .detail > .back {
    order: -4;
  }
  .detail > .detail-head {
    order: -3;
  }
  .detail > .banner {
    order: -2;
  }
  .detail > .panel.act {
    order: -1;
    border: 2px solid var(--accent);
  }
  .detail-head {
    padding: 14px 16px;
  }
  /* later than the base rule, so the small button is still 44 px tall on a phone */
  .btn.small,
  .icon-btn {
    min-height: 44px;
  }
  .icon-btn {
    min-width: 44px;
  }
  .stage-actions .btn,
  .actions-bar .btn {
    flex: 1 1 140px;
  }
  .note-input {
    flex-basis: 100%;
  }
  /* Dialogs rise from the bottom like a sheet */
  dialog.modal,
  dialog.modal.wide {
    width: 100vw;
    max-width: 100vw;
    max-height: 92vh;
    margin: auto 0 0;
    border-radius: 16px 16px 0 0;
  }
  .modal-head,
  .modal-body {
    padding-inline: 16px;
  }
  .modal-actions .btn {
    flex: 1 1 140px;
  }
  /* Toasts sit above the bottom bar */
  #toast-wrap {
    bottom: 84px;
  }
  .bank-row {
    min-height: 56px;
  }
  .queue-item .stage-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .queue-item .note-input {
    grid-column: 1 / -1;
  }
  .queue-item .stage-actions .btn:last-child {
    grid-column: 1 / -1;
  }
}

/* "New": what to create, as three cards (S3). Selected, hovered and focused cards use the
   brand's selected style (accent-soft fill, accent outline, accent-ink text). */
.type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}
.type-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  min-height: 140px;
  padding: var(--space-5);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--surface-card);
  color: var(--ink);
  font: inherit;
  text-align: start;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    border-color 0.15s ease;
}
.type-card-title {
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 24px;
  font-weight: 600;
}
.type-card-desc {
  color: var(--ink-muted);
  font-size: 14px;
  line-height: 21px;
}
.type-card:hover,
.type-card:focus-visible {
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  color: var(--accent-ink);
}
.type-card:hover .type-card-desc,
.type-card:focus-visible .type-card-desc {
  color: var(--accent-ink);
}
.type-card:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
@media (max-width: 620px) {
  .type-cards {
    grid-template-columns: 1fr;
  }
  .type-card {
    min-height: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .type-card {
    transition: none;
  }
}
