/* ── Design tokens ─────────────────────────────────────────── */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-soft: #fef2f2;
  --success: #059669;
  --success-hover: #047857;
  --success-soft: #ecfdf5;
  --warn: #b45309;
  --warn-hover: #92400e;
  --warn-soft: #fffbeb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
  --sidebar-w: 260px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .85em;
}

.muted { color: var(--text-muted); margin: 4px 0 0; font-size: .9rem; }
.ta-right { text-align: right; }
.req { color: var(--danger); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: .9rem;
  cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); }

.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--surface-2); border-color: #cbd5e1; }

.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-hover); }
.btn--success { background: var(--success); color: #fff; }
.btn--success:hover { background: var(--success-hover); }
.btn--warn { background: var(--warn); color: #fff; }
.btn--warn:hover { background: var(--warn-hover); }

.btn--sm { padding: 6px 12px; font-size: .82rem; }
.btn--block { width: 100%; }

/* ── Layout ────────────────────────────────────────────────── */
.page-centered {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 24px;
}
.page-login {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #2563eb 100%);
}

.app { min-height: 100vh; }

.main {
  margin-left: var(--sidebar-w);
  padding: 32px clamp(16px, 4vw, 40px) 64px;
  max-width: 1400px;
}
.main__header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.main__title { margin: 0; font-size: 1.6rem; letter-spacing: -.02em; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: #0f172a;
  color: #cbd5e1;
  display: flex; flex-direction: column;
  padding: 24px 16px;
  z-index: 40;
  transition: transform .25s ease;
}
.sidebar__brand { padding: 0 8px 24px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar__logo {
  display: block; font-size: 1.5rem; font-weight: 800;
  letter-spacing: .08em; color: #fff;
}
.sidebar__sub { font-size: .78rem; color: #94a3b8; letter-spacing: .04em; text-transform: uppercase; }

.sidebar__nav { display: flex; flex-direction: column; gap: 4px; padding-top: 20px; flex: 1; }
.sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: #cbd5e1; text-decoration: none; font-size: .92rem; font-weight: 500;
  transition: background-color .15s, color .15s;
}
.sidebar__link:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar__link.is-active { background: var(--primary); color: #fff; }
.sidebar__icon { width: 18px; text-align: center; opacity: .9; }

.sidebar__footer { border-top: 1px solid rgba(255,255,255,.08); padding-top: 16px; }
.sidebar__user { display: flex; align-items: center; gap: 10px; padding: 0 4px 14px; }
.sidebar__avatar {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700;
}
.sidebar__username { color: #fff; font-size: .9rem; font-weight: 600; }
.sidebar__role { font-size: .75rem; color: #94a3b8; }

.nav-toggle {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 60;
  width: 42px; height: 42px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 1.1rem; cursor: pointer;
}
.scrim {
  position: fixed; inset: 0; z-index: 35;
  background: rgba(15,23,42,.5);
}
.scrim[hidden] { display: none; }

/* ── Cards & login ─────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card--message { max-width: 440px; text-align: center; }
.card__title { margin: 0 0 8px; font-size: 1.25rem; }
.card--message .btn { margin-top: 20px; }

.login {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
  padding: 40px 32px;
}
.login__brand { text-align: center; margin-bottom: 24px; }
.login__logo {
  display: inline-grid; place-items: center;
  width: 56px; height: 56px; margin-bottom: 14px;
  border-radius: 14px;
  background: var(--primary); color: #fff;
  font-weight: 800; letter-spacing: .05em;
}
.login__title { margin: 0; font-size: 1.4rem; letter-spacing: -.02em; }

/* ── Forms ─────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: .85rem; font-weight: 600; color: #334155; }
.field__input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit; font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.field__input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.field__group { position: relative; display: flex; }
.field__group .field__input { padding-right: 68px; }
.field__toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--primary);
  font: inherit; font-size: .82rem; font-weight: 600;
  cursor: pointer; padding: 6px 8px; border-radius: 6px;
}
.field__toggle:hover { background: var(--primary-soft); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Checkbox row for the boolean `ready` column. */
.check {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
}
.check:hover { border-color: var(--primary); }
.check input { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; margin: 0; }
.check__text { font-size: .92rem; color: var(--text); }
.hint { margin: 2px 0 0; font-size: .78rem; color: var(--text-muted); }

.form__grid { display: grid; grid-template-columns: 240px 1fr; gap: 28px; }
.form__fields { display: flex; flex-direction: column; gap: 18px; }
.form__photo { display: flex; flex-direction: column; gap: 10px; }
.form__actions {
  display: flex; justify-content: flex-end; gap: 12px;
  border-top: 1px solid var(--border); padding-top: 20px;
}

.photo-preview {
  position: relative;
  aspect-ratio: 4 / 3;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: grid; place-items: center;
  overflow: hidden;
}
.photo-preview img { width: 100%; height: 100%; object-fit: cover; }
.photo-preview__empty { color: var(--text-muted); font-size: .85rem; }

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: .9rem;
  border: 1px solid transparent;
}
.alert--error { background: var(--danger-soft); color: #991b1b; border-color: #fecaca; }
.alert--success { background: var(--success-soft); color: #065f46; border-color: #a7f3d0; }
.alert__list { margin: 8px 0 0; padding-left: 20px; }
.login .alert { margin-bottom: 18px; }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th {
  text-align: left;
  padding: 13px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: .76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
  white-space: nowrap;
}
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }

.thumb {
  width: 56px; height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-2);
  display: block;
}
.thumb--empty { display: grid; place-items: center; font-size: 1.1rem; opacity: .45; }

.chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-size: .78rem; font-weight: 600;
  white-space: nowrap;
}

/* Yes/no pill for the boolean `ready` column. */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  white-space: nowrap;
}
.badge--yes { background: var(--success-soft); color: #065f46; }
.badge--no { background: var(--surface-2); color: var(--text-muted); }
.badge--approved { background: var(--success-soft); color: #065f46; }
.badge--disapproved { background: var(--danger-soft); color: #991b1b; }
.badge--pending { background: var(--warn-soft); color: var(--warn); }

/* Right-aligned integer cells. */
.num { font-variant-numeric: tabular-nums; }

/* Method chip stacked above its account number. */
.pay-cell { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.pay-cell__number {
  font-size: .82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.row-actions { display: inline-flex; gap: 8px; justify-content: flex-end; }
.row-actions form { display: inline; margin: 0; }

/* ── Empty state ───────────────────────────────────────────── */
.empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 64px 24px; text-align: center;
}
.empty__icon { font-size: 2.5rem; opacity: .5; }
.empty__title { margin: 12px 0 4px; font-size: 1.15rem; }
.empty .btn { margin-top: 20px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(15, 23, 42, .55);
  padding: 20px;
}
/* An author `display` beats the UA [hidden] rule, so restore it explicitly. */
.modal[hidden] { display: none; }
.modal__panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 26px;
  width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(15,23,42,.35);
}
.modal__title { margin: 0 0 10px; font-size: 1.15rem; }
.modal__body { margin: 0; font-size: .95rem; }
.modal__note { margin-top: 6px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .form__grid { grid-template-columns: 1fr; }
  .photo-preview { max-width: 280px; }
}

@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.is-open { transform: translateX(0); }
  /* Clear the fixed toggle button so it never covers the brand. */
  .sidebar__brand { padding-left: 56px; }
  .main { margin-left: 0; padding-top: 72px; }
  .main__header { flex-direction: column; align-items: stretch; }
  .main__header .btn { width: 100%; }
  .field-row { grid-template-columns: 1fr; }
  .form__actions { flex-direction: column-reverse; }
  .form__actions .btn { width: 100%; }

  /* Stacked card layout replaces the table on small screens. */
  .table-wrap { border: 0; background: none; box-shadow: none; overflow: visible; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    padding: 6px 4px;
  }
  .table td {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; text-align: right; border-bottom: 1px solid var(--border);
  }
  .table td:last-child { border-bottom: 0; }
  .table td::before {
    content: attr(data-label);
    font-size: .74rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .05em; color: var(--text-muted);
    text-align: left; flex: none;
  }
  .pay-cell { align-items: flex-end; }
  .row-actions { width: 100%; justify-content: flex-end; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ── Approval Management ───────────────────────────────────── */
.bulk-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.bulk-actions form { margin: 0; }

.approvals {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.approval { display: flex; flex-direction: column; gap: 12px; }
.approval__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
}
.approval__name {
  margin: 0; font-size: 1rem; font-weight: 700;
  letter-spacing: -.01em; word-break: break-word;
}

.approval__receipt {
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  display: grid; place-items: center;
  overflow: hidden;
}
.approval__receipt a { display: block; width: 100%; height: 100%; }
.approval__receipt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.approval__noreceipt { color: var(--text-muted); font-size: .85rem; }

.approval__meta { margin: 0; font-size: .82rem; color: var(--text-muted); }
.approval__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: auto; }
.approval__actions form { margin: 0; }
/* Any card or table row mid-request: greyed out and unclickable. */
[data-approval-id].is-busy { opacity: .6; pointer-events: none; }

@media (max-width: 560px) {
  .bulk-actions { width: 100%; }
  .bulk-actions .btn { flex: 1; }
}

/* ── Blocked users ─────────────────────────────────────────── */
/* `etas.blocked` is a per-user flag an admin sets from the Approvals,
   Approved Users or Blocked Users screen. Nothing here deletes a row. */
.badge--blocked { background: var(--danger); color: #fff; }

/* Status pills sit together at the top-right of an approval card. */
.badges { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* A blocked user reads as blocked at a glance, card or table row alike. */
.approval.is-blocked { border-color: var(--danger); }
tr.is-blocked > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.is-blocked td[data-label="Name"] strong { color: var(--danger-hover); }
td[data-label="Name"] .badge--blocked { margin-left: 8px; }

/* The per-user action buttons wrap instead of stretching a table column. */
.row-actions { flex-wrap: wrap; }
