:root {
  --bg: #f3f6f4;
  --bg-accent: #e7efe9;
  --surface: #ffffff;
  --ink: #15241c;
  --muted: #5d6f65;
  --line: #d5e0d8;
  --brand: #0f6b4c;
  --brand-dark: #0a4d37;
  --brand-soft: #d9efe5;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --error: #9b1c1c;
  --error-bg: #fde8e8;
  --success: #0f6b4c;
  --success-bg: #e3f6ec;
  --shadow: 0 10px 30px rgba(21, 36, 28, 0.06);
  --radius: 14px;
  --font: "Segoe UI", "Tahoma", "Arial", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, #d9efe5 0%, transparent 40%),
    linear-gradient(180deg, #f7faf8 0%, var(--bg) 100%);
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--brand), var(--brand-dark));
  color: white;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
}

.brand p {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.lang-switch {
  display: inline-flex;
  background: var(--bg-accent);
  border-radius: 999px;
  padding: 0.2rem;
  gap: 0.2rem;
}

.lang-btn {
  text-decoration: none;
  color: var(--muted);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
}

.lang-btn.active {
  background: white;
  color: var(--brand-dark);
  box-shadow: var(--shadow);
  font-weight: 600;
}

.container {
  width: 98%;
  max-width: none;
  margin: 0.5rem auto 1rem;
  display: grid;
  gap: 0.75rem;
}

.panel {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.panel h2,
.panel h3 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

.search-hint {
  margin: -0.35rem 0 1rem;
  font-size: 0.88rem;
}

.panel-search {
  position: relative;
}

.panel-cchi-tag {
  position: absolute;
  top: 0.65rem;
  inset-inline-start: 0.85rem;
  font-size: 0.72rem;
  line-height: 1;
  font-family: ui-monospace, Consolas, monospace;
  letter-spacing: 0.03em;
  color: var(--muted);
  pointer-events: none;
  user-select: none;
}

.panel-cchi-tag--null {
  color: var(--error);
  font-weight: 600;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.3fr) minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 0.85rem;
  align-items: end;
}

.search-form .btn {
  min-height: 44px;
  white-space: nowrap;
  padding-inline: 1.25rem;
}

.field-error {
  margin: 0.75rem 0 0;
  color: var(--error);
  font-size: 0.88rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input[type="text"],
input[type="date"],
input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: #fcfdfc;
}

input:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 35%, white);
  border-color: var(--brand);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--bg-accent);
  color: var(--ink);
}

.btn-primary {
  background: var(--brand);
  color: white;
}

.btn-primary:hover { background: var(--brand-dark); }

.btn-danger {
  background: #b42318;
  color: white;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: start;
  padding: 0.75rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--bg-accent);
}

.status-PENDING { background: #fff4d6; color: #8a5a00; }
.status-DISPENSED, .status-APPROVED, .status-FULLY_DISPENSED { background: var(--success-bg); color: var(--success); }
.status-CANCELLED, .status-REJECTED, .status-EXPIRED { background: var(--error-bg); color: var(--error); }
.status-NOT_DISPENSED { background: #fde8e8; color: #9b1c1c; }
.status-PARTIALLY_DISPENSED { background: #e8eefc; color: #1d4ed8; }

.alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
}

.alert-error { background: var(--error-bg); color: var(--error); border-color: #f3c1c1; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #b7e4c7; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f0d48a; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.toolbar h2 {
  margin: 0;
  font-size: 1.1rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 0.45rem 0.75rem;
  margin: 0;
}

.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.plain-list {
  margin: 0;
  padding-inline-start: 1.1rem;
}

.action-bar {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
  align-items: center;
}

.action-bar__group {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.action-bar .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.qty-input {
  width: 90px;
}

.col-warn {
  width: 2rem;
  text-align: center;
}

.col-stock-arrow {
  width: 2.5rem;
  text-align: center;
  padding-inline: 0.15rem;
}

.stock-warn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  font-size: 1rem;
  line-height: 1;
  cursor: help;
}

.stock-warn--low {
  color: #ea580c;
}

.stock-warn--zero {
  color: #dc2626;
}

.stock-cell {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.btn-stock-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #eef8f1;
  color: #166534;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
}

[dir="rtl"] .btn-stock-copy {
  transform: scaleX(-1);
}

.btn-stock-copy:hover:not(:disabled) {
  background: #d8f0df;
}

.btn-stock-copy:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: #f1f3f2;
  color: #6b7280;
}

.chip {
  display: inline-block;
  margin: 0.2rem 0.25rem;
  padding: 0.25rem 0.55rem;
  background: var(--bg-accent);
  border-radius: 999px;
  font-size: 0.8rem;
}

.panel-dispensed {
  border-color: #c8e6d4;
  background: linear-gradient(180deg, #f8fdf9 0%, var(--surface) 100%);
}

.dispensed-list {
  display: grid;
  gap: 0.85rem;
}

.dispensed-history-title {
  margin: 0 0 0.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.dispensed-card {
  border: 1px solid #d4eadc;
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  background: #fff;
}

.dispensed-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.dispensed-card__title {
  flex: 1;
  min-width: 0;
  font-weight: 600;
}

.dispensed-card__table-wrap {
  margin: 0;
  border-radius: 8px;
  border: 1px solid #e3efe8;
}

.dispensed-history-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.dispensed-history-table th,
.dispensed-history-table td {
  padding: 0.55rem 0.7rem;
  text-align: start;
  border-bottom: 1px solid #eef3f0;
  vertical-align: top;
}

.dispensed-history-table thead th {
  background: #f3faf6;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
}

.dispensed-history-table tbody tr:last-child td {
  border-bottom: none;
}

.dispensed-history-table code {
  font-size: 0.85em;
}

.row-cancel-blocked {
  opacity: 0.72;
  background: #fafafa;
}

.row-cancel-blocked .qty-input:disabled {
  cursor: not-allowed;
}

.dispensed-card__meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem 1rem;
  margin: 0;
}

.dispensed-card__meta > div {
  display: grid;
  gap: 0.15rem;
}

.dispensed-card__meta dt {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.dispensed-card__meta dd {
  margin: 0;
  font-weight: 500;
}

@media (min-width: 640px) {
  .dispensed-card__meta {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.subrow td {
  background: #fafcfb;
  font-size: 0.85rem;
}

code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.88em;
}

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

body.modal-open {
  overflow: hidden;
}

body.loader-active {
  overflow: hidden;
}

.page-loader {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  background: rgba(247, 250, 248, 0.72);
  pointer-events: all;
}

.page-loader[hidden] {
  display: none !important;
}

.page-loader__spinner {
  display: grid;
  place-items: center;
}

/* لودر دائري بأسلوب تبويب Microsoft Edge */
.page-loader__edge {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 3px solid rgba(0, 120, 212, 0.18);
  border-top-color: #0078d4;
  border-right-color: #0078d4;
  animation: page-loader-edge-spin 0.7s linear infinite;
}

.ui-modal__loader .page-loader__edge {
  width: 2.25rem;
  height: 2.25rem;
}

@keyframes page-loader-edge-spin {
  to {
    transform: rotate(360deg);
  }
}

.ui-modal[hidden] {
  display: none !important;
}

.ui-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.ui-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 36, 28, 0.45);
}

.ui-modal__dialog {
  position: relative;
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(21, 36, 28, 0.2);
  padding: 1.15rem 1.2rem;
  z-index: 1;
}

.ui-modal__title {
  margin: 0 0 0.55rem;
  font-size: 1.05rem;
}

.ui-modal__message {
  margin: 0 0 1.1rem;
  color: var(--ink);
  line-height: 1.5;
}

.ui-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.toast-stack {
  position: fixed;
  inset-inline-end: 1.25rem;
  bottom: 2.25rem;
  z-index: 1100;
  display: grid;
  gap: 0.55rem;
  width: min(420px, calc(100% - 2.5rem));
  pointer-events: none;
}

/* عربي: الإشعار أسفل يمين الشاشة (وليس حسب inline-end في RTL) */
html[dir="rtl"] .toast-stack {
  inset-inline-end: auto;
  right: 1.25rem;
  left: auto;
}

.toast {
  pointer-events: auto;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  box-shadow: var(--shadow);
  background: var(--surface);
  color: var(--ink);
  animation: toast-in 0.2s ease;
  max-height: min(40vh, 280px);
  overflow-y: auto;
  line-height: 1.45;
  word-break: break-word;
  font-size: 0.9rem;
}

.form.is-busy,
form.is-busy {
  opacity: 0.72;
  pointer-events: none;
}

.toast--success {
  background: var(--success-bg);
  color: var(--success);
  border-color: #b7e4c7;
}

.toast--error {
  background: var(--error-bg);
  color: var(--error);
  border-color: #f3c1c1;
}

.toast--warn {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: #f0d48a;
}

.toast--info {
  background: #eef4ff;
  color: #1d4ed8;
  border-color: #c7d7fe;
}

.toast--hide {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ——— تسجيل الدخول / شريط المستخدم ——— */
body.login-page .topbar {
  display: none;
}

body.login-page .container {
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-wrap {
  width: min(440px, 100%);
}

.login-card__head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.login-card__title {
  margin: 0;
  font-size: 1.35rem;
}

.login-card__subtitle {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-form label.is-invalid input {
  border-color: var(--error);
}

.login-form .required::after {
  content: " *";
  color: var(--error);
}

.login-submit {
  width: 100%;
  min-height: 44px;
  margin-top: 0.25rem;
}

.login-hp-field {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.login-challenge {
  display: none;
}

.login-challenge.is-visible {
  display: block;
}

.login-challenge__expr {
  display: block;
  font-weight: 600;
  color: var(--ink);
  margin: 0.25rem 0 0.35rem;
}

input[type="password"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: var(--ink);
  background: #fcfdfc;
}

.app-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--line);
}

.topbar .app-nav {
  border-top: none;
  margin-top: 0;
  padding-top: 0;
  width: auto;
  flex: 1;
}

.app-nav--guest {
  justify-content: flex-end;
}

.app-nav__links {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.app-nav__link {
  text-decoration: none;
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  font-size: 0.9rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.app-nav__link.is-active,
.app-nav__link:hover {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.app-nav__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.app-nav__user {
  position: relative;
}

.app-nav__user-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  padding: 0.35rem 0.65rem 0.35rem 0.45rem;
  min-height: 44px;
  cursor: pointer;
  font: inherit;
  color: var(--ink);
}

.app-nav__user-name {
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.app-nav__menu {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 0.35rem);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
  z-index: 20;
}

.app-nav__menu[hidden] {
  display: none !important;
}

.app-nav__menu-item {
  display: block;
  width: 100%;
  text-align: start;
  border: none;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
  min-height: 44px;
}

.app-nav__menu-item:hover {
  background: var(--bg-accent);
}

.app-nav__menu-item--danger {
  color: var(--error);
}

.app-nav__divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0.25rem 0;
}

.profile-panel h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.profile-grid {
  margin-top: 0.5rem;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-decoration: none;
  color: inherit;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 1;
}

.branch-select-wrap { min-width: 140px; }

.branch-select-wrap.is-locked .branch-select {
  opacity: 0.65;
  cursor: not-allowed;
  background: #eef2ef;
}

.branch-select,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--ink);
  background: #fcfdfc;
  min-height: 44px;
}

.filter-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  background: #f8fbf9;
}

.filter-card__title {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.users-filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.users-filter-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.users-meta { margin-bottom: 0.75rem; }

.users-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* ——— التقارير ——— */
.reports-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.reports-toolbar h2 {
  margin: 0;
  font-size: 1.15rem;
}

.reports-filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.85rem;
  align-items: end;
}

.reports-filter-form--summary .reports-field--detail {
  display: none;
}

.reports-filter-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-start;
  padding-top: 0.25rem;
}

.reports-filter-actions .btn {
  white-space: nowrap;
  min-height: 44px;
  flex: 0 1 auto;
  min-width: 140px;
}

.btn-excel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.btn-excel__icon {
  flex-shrink: 0;
  display: block;
}

.page-bottom-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
  padding: 0.85rem 0 0.15rem;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: var(--surface);
  z-index: 5;
}

html[dir="rtl"] .page-bottom-actions {
  justify-content: flex-start;
}

.page-bottom-actions .btn {
  min-height: 44px;
}

.reports-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.reports-field--branches,
.reports-field--med {
  grid-column: span 1;
  min-width: 0;
}

.ms-select {
  position: relative;
}

.ms-select__btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: #fcfdfc;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  text-align: start;
}

.ms-select__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-select__panel {
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + 0.25rem);
  z-index: 30;
  width: min(100%, 320px);
  max-height: 240px;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.35rem;
}

.ms-select__option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  min-height: 44px;
  cursor: pointer;
  margin: 0;
}

.ms-select__option:hover {
  background: var(--bg-accent);
}

.ms-select__option input {
  width: 1.1rem;
  height: 1.1rem;
  flex-shrink: 0;
}

.ms-select__empty {
  margin: 0.5rem;
}

.combo {
  position: relative;
}

.combo__list {
  position: absolute;
  inset-inline-start: 0;
  top: calc(100% + 0.25rem);
  z-index: 30;
  width: 100%;
  max-height: 220px;
  overflow: auto;
  margin: 0;
  padding: 0.25rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.combo__item {
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  min-height: 44px;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.combo__item:hover {
  background: var(--bg-accent);
}

.reports-table-wrap {
  --reports-head-h: 3rem;
  max-height: min(70vh, 720px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.reports-table {
  width: 100%;
  min-width: 960px;
  border-collapse: separate;
  border-spacing: 0;
}

.reports-table thead tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f3f7f4;
  vertical-align: bottom;
  box-shadow: 0 1px 0 var(--line);
}

.reports-table thead tr.col-filters th {
  position: sticky;
  top: var(--reports-head-h);
  z-index: 2;
  background: #eef4f0;
  padding-top: 0.35rem;
  padding-bottom: 0.45rem;
  box-shadow: 0 1px 0 var(--line);
}

.reports-table .col-summary-only {
  display: none;
}

.reports-table--summary .col-detail-only {
  display: none;
}

.reports-table--summary .col-summary-only {
  display: table-cell;
}

.reports-table--summary {
  min-width: 820px;
}

.th-sort {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  padding: 0.15rem 0;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  text-align: start;
}

.th-sort.is-sorted::after {
  content: "▾";
  font-size: 0.75rem;
  opacity: 0.8;
}

.th-sort.is-asc::after {
  content: "▴";
}

.col-filter {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  font: inherit;
  font-size: 0.8rem;
  background: #fcfdfc;
  min-height: 36px;
}

.reports-scroll-status {
  text-align: center;
  padding: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.reports-sentinel {
  height: 8px;
}

@media (max-width: 640px) {
  .reports-filter-form {
    grid-template-columns: 1fr;
  }

  .reports-filter-actions {
    width: 100%;
  }

  .reports-filter-actions .btn {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 0;
  }

  .ms-select__panel {
    width: 100%;
  }

  .reports-table-wrap {
    max-height: 60vh;
  }
}

.ui-modal__dialog--wide { width: min(560px, 100%); }
.ui-modal__dialog--xl { width: min(960px, 100%); }

.change-password-form {
  display: grid;
  gap: 0.85rem;
}

.change-password-form label.required > span:first-child::after,
label.required > span:first-child::after {
  content: " *";
  color: var(--error);
}

.change-password-form label.is-invalid input,
label.is-invalid input {
  border-color: var(--error);
}

.change-password-form .field-error {
  margin: 0;
  min-height: 1.1em;
  font-size: 0.82rem;
}

.ui-modal__loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(252, 253, 252, 0.72);
  border-radius: inherit;
  z-index: 5;
}

.ui-modal__loader[hidden] {
  display: none !important;
}

.user-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.user-form-actions {
  grid-column: 1 / -1;
  margin-top: 0.5rem;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
}

.dual-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.dual-list__col h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

.dual-list__search {
  width: 100%;
  margin-bottom: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  min-height: 44px;
}

.dual-list__table-wrap {
  max-height: 320px;
  overflow: auto;
}

@media (max-width: 860px) {
  .dual-list,
  .user-form-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 860px) {
  .container {
    width: 98%;
    margin: 0.35rem auto 0.75rem;
  }

  .search-form,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .kv {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .toast-stack {
    inset-inline: 0.75rem;
    bottom: 1.75rem;
    width: auto;
  }

  html[dir="rtl"] .toast-stack {
    left: 0.75rem;
    right: 0.75rem;
  }

  .ui-modal__actions {
    flex-direction: column-reverse;
  }

  .ui-modal__actions .btn {
    width: 100%;
    min-height: 44px;
  }
}
