:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --panel: #ffffff;
  --panel-soft: #f8faf8;
  --ink: #121a15;
  --muted: #627068;
  --line: #dce5df;
  --brand: #15803d;
  --brand-dark: #166534;
  --primary: #15803d;
  --primary-hover: #166534;
  --brand-soft: #eaf6ee;
  --brand-border: #b9dfc7;
  --red: #eb0045;
  --red-soft: #ffe8ef;
  --info: #23845b;
  --info-soft: #edf6f0;
  --yellow: #f5b335;
  --green: #1a7f37;
  --green-soft: #e7f6ec;
  --amber: #916000;
  --amber-soft: #fff5db;
  --accent: #15803d;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 14px 32px rgba(12, 35, 20, 0.08);
  --shadow-soft: 0 8px 22px rgba(12, 35, 20, 0.06);
  --focus-ring: 0 0 0 3px rgba(34, 139, 74, 0.3);
  --rail-bg: #0d1710;
  --rail-accent: #86efac;
  --rail-chip-bg: rgba(255, 255, 255, 0.1);
  --secondary-hover: #e9f2ec;
  --zebra: #f8fbf9;
  --actions-bg: #f0f8f2;
  --actions-border: #c5e4d0;
  --neutral-soft: #ecf1ee;
  --map-bg: #edf6f0;
  --danger-bg: #eb0045;
  --danger-bg-hover: #bd0037;
  --green-border: #bfe6cb;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b100d;
  --panel: #131c16;
  --panel-soft: #19251d;
  --ink: #f1f7f3;
  --muted: #adbcaf;
  --line: #304436;
  --brand-dark: #86efac;
  --primary: #15803d;
  --primary-hover: #166534;
  --brand-soft: #1a3021;
  --brand-border: #366047;
  --red: #ff5a87;
  --red-soft: #3c1530;
  --info: #6dcea1;
  --info-soft: #1b3025;
  --yellow: #f5b335;
  --green: #5ec97f;
  --green-soft: #1e3325;
  --amber: #e0af58;
  --amber-soft: #3a2d18;
  --shadow: 0 14px 32px rgba(0, 0, 0, 0.4);
  --shadow-soft: 0 8px 22px rgba(0, 0, 0, 0.35);
  --rail-bg: #0d1710;
  --rail-accent: #86efac;
  --rail-chip-bg: rgba(255, 255, 255, 0.06);
  --secondary-hover: #23372a;
  --zebra: #152219;
  --actions-bg: #16291d;
  --actions-border: #36553e;
  --neutral-soft: #24352a;
  --map-bg: #16271c;
  --danger-bg: #eb0045;
  --danger-bg-hover: #c8003b;
  --green-border: #2e5238;
}

@font-face {
  font-family: "Tajawal";
  src: url("/static/assets/tajawal-regular.ttf?v=20260901-fontfix1") format("truetype");
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
}

@font-face {
  font-family: "Tajawal";
  src: url("/static/assets/tajawal-bold.ttf?v=20260901-fontfix1") format("truetype");
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

html[lang="en"] body {
  font-family: "Poppins", "Segoe UI", Arial, sans-serif;
}

::selection {
  background: rgba(34, 139, 74, 0.24);
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-weight: 800;
  padding: 10px 16px;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

button svg {
  width: 17px;
  height: 17px;
  flex: none;
}

button:hover {
  background: var(--primary-hover);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible,
select:focus-visible,
.case-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.secondary {
  background: var(--brand-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.secondary:hover {
  background: var(--secondary-hover);
}

.danger-btn {
  background: var(--danger-bg);
  color: #fff;
}

.danger-btn:hover {
  background: var(--danger-bg-hover);
}

.icon-only {
  width: 42px;
  padding: 10px;
}

.ghost-btn {
  min-height: 36px;
  padding: 7px 11px;
  background: transparent;
  color: var(--brand-dark);
  border: 1px solid transparent;
  font-size: 13px;
}

.ghost-btn:hover {
  background: var(--brand-soft);
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 200;
  inset-block-start: 10px;
  inset-inline-start: 10px;
  transform: translateY(-150%);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  font-weight: 800;
  text-decoration: none;
}

.skip-link:focus {
  transform: none;
}

.eyebrow,
.muted {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

/* ---------- login ---------- */

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
}

.login-visual {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 56px;
  color: white;
  background:
    radial-gradient(ellipse at 80% 10%, rgba(34, 197, 94, 0.3), transparent 48%),
    radial-gradient(ellipse at 5% 50%, rgba(21, 128, 61, 0.22), transparent 55%),
    linear-gradient(145deg, #122e1c 0%, #0c1710 58%, #080d09 100%);
}

.login-visual::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 64%;
  aspect-ratio: 1;
  top: 12%;
  left: -16%;
  border: 1px solid rgba(134, 239, 172, 0.2);
  border-radius: 50%;
  box-shadow: 0 0 0 60px rgba(134, 239, 172, 0.04), 0 0 0 120px rgba(134, 239, 172, 0.03);
}

.login-visual::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(0deg, rgba(5, 20, 10, 0.72), transparent 58%);
}

.login-visual .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

.login-visual h1 {
  max-width: 720px;
  margin: 10px 0 14px;
  font-size: 52px;
  line-height: 1.08;
}

.login-visual p:last-child {
  max-width: 650px;
  margin: 0;
  font-size: 18px;
  line-height: 1.8;
}

.login-form {
  align-self: center;
  justify-self: center;
  width: min(420px, calc(100vw - 36px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-brand {
  min-height: 94px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -4px 0 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.wasila-logo {
  display: block;
  position: relative;
  overflow: hidden;
  width: 270px;
  max-width: 100%;
  aspect-ratio: 2.4;
  background: #fff;
  border-radius: 8px;
}

.wasila-logo img {
  position: absolute;
  width: 120%;
  max-width: none;
  height: auto;
  left: -10%;
  top: -70%;
}

.rail-logo { width: 176px; flex: none; }

.wasila-logo.brand-on-dark {
  display: none;
  background: transparent;
  aspect-ratio: 4.2;
  border-radius: 0;
}

.wasila-logo.brand-on-dark img { top: -178%; }
.rail-logo.brand-on-dark,
:root[data-theme="dark"] .brand-on-dark { display: block; }
:root[data-theme="dark"] .brand-on-light { display: none; }

.login-form h2,
.topbar h2,
.panel h3,
.queue-panel h3,
.case-details h3 {
  margin: 6px 0 18px;
}

.login-form button[type="submit"] {
  width: 100%;
  margin-top: 4px;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-inline-end: 72px;
}

.password-field .ghost-btn {
  position: absolute;
  top: 50%;
  inset-inline-end: 6px;
  transform: translateY(-50%);
  min-height: 30px;
  font-weight: 800;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 139, 74, 0.2);
  outline: none;
}

input[type="search"]::-webkit-search-cancel-button {
  cursor: pointer;
}

textarea {
  min-height: 76px;
  resize: vertical;
  font-size: 14px;
}

.error-text {
  min-height: 20px;
  color: var(--red);
  font-weight: 700;
}

/* ---------- layout ---------- */

.desk-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--rail-bg);
  color: #fff;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
}

.rail .eyebrow {
  color: var(--rail-accent);
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 26px;
}

.rail h1 {
  margin: 2px 0 0;
  font-size: 20px;
  color: #fff;
}

nav {
  display: grid;
  gap: 8px;
}

.nav-btn {
  width: 100%;
  justify-content: flex-start;
  text-align: start;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  min-height: 42px;
  font-weight: 700;
}

.nav-btn svg {
  color: #86efac;
}

.nav-btn:hover {
  background: var(--rail-chip-bg);
}

.nav-btn.active {
  background: #fff;
  color: #121a15;
  border-color: rgba(255, 255, 255, 0.8);
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.rail-bottom {
  display: grid;
  gap: 12px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--rail-chip-bg);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 10px;
}

.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 999px;
  background: #15803d;
  color: #fff;
  font-weight: 900;
  font-size: 16px;
}

.user-chip-text {
  min-width: 0;
  display: grid;
}

.user-chip-text strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip-text small {
  color: var(--rail-accent);
  font-weight: 800;
  font-size: 11px;
}

.rail .secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.16);
}

.rail .secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

.workspace {
  min-width: 0;
  padding: 20px 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  margin-bottom: 12px;
}

.topbar h2 {
  font-size: 24px;
  margin-bottom: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.refresh-meta {
  font-size: 12px;
  font-weight: 700;
  margin-top: 3px;
}

.refresh-meta.stale {
  color: var(--red);
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.connection-status i {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 999px;
  background: var(--muted);
  box-shadow: 0 0 0 3px var(--neutral-soft);
}

.connection-status.live {
  color: var(--green);
}

.connection-status.live i {
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}

.connection-status.retry {
  color: var(--amber);
}

.connection-status.retry i {
  background: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-soft);
}

.connection-status.stopped {
  color: var(--red);
}

.connection-status.stopped i {
  background: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}

.refresh-icon {
  transition: transform 0.4s ease;
}

.lang-btn {
  font-weight: 800;
  min-width: 74px;
}

.login-lang {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.login-lang .ghost-btn {
  min-height: 30px;
  min-width: auto;
  padding: 4px 10px;
}

#themeToggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] #themeToggle .icon-sun {
  display: inline;
}

:root[data-theme="dark"] #themeToggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .login-visual {
  filter: brightness(0.85);
}

#refreshBtn.loading .refresh-icon {
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(-360deg);
  }
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  bottom: 18px;
  inset-inline-end: 18px;
  z-index: 90;
  display: grid;
  gap: 8px;
  max-width: min(380px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--brand);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 11px 12px;
  font-weight: 700;
  animation: fade-up 0.22s ease;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.toast-icon {
  display: inline-flex;
  flex: none;
}

.toast-icon svg {
  width: 20px;
  height: 20px;
}

.toast.success {
  border-inline-start-color: var(--green);
}

.toast.success .toast-icon {
  color: var(--green);
}

.toast.error {
  border-inline-start-color: var(--red);
}

.toast.error .toast-icon {
  color: var(--red);
}

.toast.info {
  border-inline-start-color: var(--brand);
}

.toast.info .toast-icon {
  color: var(--brand-dark);
}

.toast-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast-close {
  min-height: 40px;
  width: 40px;
  padding: 0;
  flex: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  font-weight: 700;
}

.toast-close:hover {
  background: var(--panel-soft);
}

/* ---------- modal & drawer ---------- */

.modal-backdrop,
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(5, 20, 10, 0.52);
  animation: fade-up 0.18s ease;
}

.modal-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal-card {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}

.modal-card h3 {
  margin: 0 0 10px;
  font-size: 20px;
}

.modal-card p {
  margin: 0 0 12px;
  color: var(--ink);
  line-height: 1.7;
}

.confirm-note {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.confirm-warning {
  color: var(--amber);
  font-weight: 800;
  font-size: 13px;
}

.manual-deduction {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

.manual-deduction small {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.6;
}

.money-input {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.money-input strong {
  color: var(--accent-strong);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

.modal-actions button {
  flex: 1;
}

.drawer {
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  height: 100%;
  width: min(400px, calc(100vw - 40px));
  background: var(--panel);
  border-inline-start: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  animation: drawer-in 0.22s ease;
}

@keyframes drawer-in {
  from {
    transform: translateX(-30px);
    opacity: 0;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h3 {
  margin: 0;
  font-size: 18px;
}

.drawer-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.drawer-desc {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.8;
}

.threshold-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.threshold {
  display: grid;
  gap: 2px;
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
}

.threshold b {
  font-size: 22px;
}

.threshold span {
  font-size: 12px;
  font-weight: 800;
}

.threshold.suspicious {
  background: var(--amber-soft);
  color: var(--amber);
}

.threshold.high {
  background: var(--red-soft);
  color: var(--red);
}

.drawer-body h4 {
  margin: 0 0 10px;
}

.rule-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.rule-rows li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 700;
}

.rule-rows b {
  color: var(--brand-dark);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.rule-rows li.reduces b {
  color: var(--green);
}

/* ---------- view chips (stats = filters) ---------- */

.view-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.view-chip {
  min-height: 38px;
  padding: 8px 13px;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.view-chip b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.view-chip:hover {
  background: var(--brand-soft);
  border-color: var(--brand-border);
}

.view-chip.active {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: #fff;
}

.view-chip.active b {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.view-chip.chip-danger b {
  background: var(--red-soft);
  color: var(--red);
}

.view-chip.chip-warning b {
  background: var(--amber-soft);
  color: var(--amber);
}

.view-chip.active.chip-danger b,
.view-chip.active.chip-warning b {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.period-filter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -2px 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.period-buttons {
  display: inline-flex;
  padding: 3px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.period-filter-btn {
  min-height: 32px;
  padding: 5px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.period-filter-btn.active {
  background: var(--brand-dark);
  color: #fff;
  box-shadow: var(--shadow-soft);
}

/* ---------- desk grid ---------- */

.desk-grid {
  display: grid;
  grid-template-columns: minmax(300px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.queue-panel,
.case-details,
.panel {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.queue-panel {
  position: sticky;
  top: 18px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h3 {
  margin: 0 0 4px;
}

.queue-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.export-btn {
  font-size: 12px;
}

.count-pill,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 900;
}

.count-pill {
  background: var(--brand-soft);
  color: var(--ink);
}

.pill.high {
  background: var(--red-soft);
  color: var(--red);
}

.pill.suspicious {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.normal {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.pill.status-pill {
  background: var(--panel-soft);
  color: var(--muted);
  border: 1px solid var(--line);
}

.case-queue {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 320px);
  overflow: auto;
  padding-inline-end: 4px;
  scrollbar-width: thin;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.pagination button {
  min-height: 36px;
  padding: 7px 12px;
}

.queue-tools {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.queue-tools input {
  min-height: 42px;
  background: var(--panel-soft);
}

/* ---------- case cards ---------- */

.case-card {
  display: grid;
  gap: 6px;
  width: 100%;
  cursor: pointer;
  user-select: none;
  text-align: start;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-inline-start: 4px solid #bdcfc2;
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease;
}

.case-card:hover {
  background: var(--brand-soft);
  border-color: var(--brand-border);
}

.case-card.selected {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  box-shadow: 0 0 0 2px rgba(34, 139, 74, 0.24);
}

.case-card:focus-visible {
  outline: none;
  border-color: var(--brand-dark);
}

.case-card.high {
  border-inline-start-color: var(--red);
}

.case-card.suspicious {
  border-inline-start-color: var(--amber);
}

.case-card.normal {
  border-inline-start-color: var(--brand);
}

.case-card strong {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.case-card small {
  color: var(--muted);
  font-size: 11px;
}

.case-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.case-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.case-card-footer b {
  display: inline-flex;
  min-width: 36px;
  height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.card-footer-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.card-actions {
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.14s ease;
}

.case-card:hover .card-actions,
.case-card.selected .card-actions,
.case-card:focus-within .card-actions {
  opacity: 1;
}

.qa {
  min-height: 26px;
  width: 28px;
  padding: 0;
  border-radius: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
}

.qa svg {
  width: 14px;
  height: 14px;
}

.qa:hover {
  background: var(--brand-soft);
  border-color: var(--brand-border);
  color: var(--brand-dark);
}

.qa.qa-confirm:hover {
  background: var(--green-soft);
  border-color: var(--green-border);
  color: var(--green);
}

.qa.qa-reject:hover {
  background: var(--red-soft);
  border-color: var(--red-soft);
  color: var(--red);
}

/* ---------- skeleton ---------- */

.case-card.skeleton {
  pointer-events: none;
  border-inline-start-color: var(--line);
  min-height: 104px;
}

.sk-line {
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line) 25%, var(--panel-soft) 50%, var(--line) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}

.sk-line.w30 { width: 30%; }
.sk-line.w40 { width: 40%; }
.sk-line.w55 { width: 55%; }
.sk-line.w70 { width: 70%; }

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---------- empty states ---------- */

.empty-mini,
.empty-state {
  color: var(--muted);
}

.empty-mini {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 26px 12px;
  text-align: center;
}

.empty-mini svg {
  width: 34px;
  height: 34px;
  color: var(--brand-border);
}

.empty-mini p {
  margin: 0;
  font-weight: 700;
}

.empty-mini small {
  color: var(--muted);
}

.empty-mini.all-clear svg {
  color: var(--green);
}

.empty-mini.all-clear p {
  color: var(--green);
  font-weight: 800;
}

/* ---------- case details ---------- */

.case-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.case-header-main {
  min-width: 0;
}

.case-header h3 {
  font-size: 24px;
  margin: 0 0 6px;
  overflow-wrap: anywhere;
}

.case-header-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}

.case-header-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.copy-btn {
  min-height: 40px;
  width: 40px;
  padding: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
}

.copy-btn:hover {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.copy-btn svg {
  width: 14px;
  height: 14px;
}

.tel-link {
  color: var(--brand-dark);
  font-weight: 800;
  text-decoration: none;
  direction: ltr;
  unicode-bidi: embed;
}

.tel-link:hover {
  text-decoration: underline;
}

.risk-score {
  min-width: 96px;
  flex: none;
  border-radius: var(--radius);
  background: var(--brand-dark);
  color: white;
  padding: 12px;
  text-align: center;
}

.risk-score span {
  display: block;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.75);
  font-weight: 800;
}

.risk-score strong {
  display: block;
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}

.risk-meter {
  position: relative;
  height: 6px;
  margin-top: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

.risk-meter i {
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  height: 100%;
  border-radius: 999px;
  background: #fff;
}

.risk-meter i.high {
  background: #ffd7d2;
}

.risk-meter i.suspicious {
  background: #ffe9c2;
}

.risk-meter b {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: rgba(255, 255, 255, 0.65);
}

.next-step {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0;
  background: var(--brand-soft);
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.next-step span {
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.next-step strong {
  overflow-wrap: anywhere;
}

.next-step.done {
  background: var(--green-soft);
  border-color: var(--green-border);
}

.next-step.done span {
  color: var(--green);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}

.summary-strip div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.summary-strip strong {
  overflow-wrap: anywhere;
}

.sla.ok {
  color: var(--green);
}

.sla.due_soon {
  color: var(--amber);
}

.sla.overdue {
  color: var(--red);
}

.sla.closed {
  color: var(--muted);
}

/* ---------- detail tabs ---------- */

.detail-tabs {
  display: flex;
  gap: 4px;
  margin: 16px 0 0;
  border-bottom: 1px solid var(--line);
}

.detail-tab {
  min-height: 40px;
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 14px;
  font-weight: 800;
}

.detail-tab:hover {
  background: var(--brand-soft);
  color: var(--ink);
}

.detail-tab.active {
  color: var(--brand-dark);
  border-bottom-color: var(--brand-dark);
}

.detail-tab b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 11px;
}

.detail-body {
  padding-top: 16px;
  animation: fade-up 0.18s ease;
}

.detail-body h4 {
  margin: 16px 0 8px;
}

/* ---------- map ---------- */

.map-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  background: var(--panel-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  padding: 22px;
  text-align: center;
}

.fraud-map > svg {
  display: block;
  width: 100%;
  height: auto;
  min-height: 260px;
  border-radius: var(--radius-sm);
  direction: ltr;
}

.map-bg {
  fill: var(--map-bg);
}

.map-grid {
  fill: url(#mapGrid);
  stroke: var(--brand-border);
}

.fraud-map pattern path {
  stroke: rgba(116, 107, 99, 0.2);
  stroke-width: 1;
}

.route-line {
  fill: none;
  stroke: var(--brand);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 12 10;
}

.driver-line {
  fill: none;
  stroke: #eb0045;
  stroke-width: 4;
  stroke-linecap: round;
}

.dropoff-zone {
  fill: rgba(180, 35, 24, 0.08);
  stroke: rgba(180, 35, 24, 0.35);
  stroke-width: 2;
}

.map-marker circle {
  stroke: #fff;
  stroke-width: 4;
}

.map-marker text {
  fill: #fff;
  font-family: "Tajawal", "Poppins", "Segoe UI", Tahoma, Arial, sans-serif;
  font-size: 12px;
  font-weight: 900;
  text-anchor: middle;
}

.map-marker.pickup circle {
  fill: var(--brand);
}

.map-marker.dropoff circle {
  fill: var(--red);
}

.map-marker.driver circle {
  fill: var(--brand-dark);
}

.map-legend,
.map-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.map-legend span,
.map-legend a,
.map-stats div {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.legend.pickup {
  background: var(--brand);
}

.legend.dropoff {
  background: var(--red);
}

.legend.driver {
  background: var(--brand-dark);
}

.map-stats div {
  display: grid;
  min-width: 150px;
  align-items: start;
  gap: 4px;
}

.map-stats strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.driver-trace-map {
  height: 440px;
  min-height: 320px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  direction: ltr;
  isolation: isolate;
  z-index: 0;
}
.trace-notice { background: var(--panel-soft); border-inline-start: 3px solid var(--brand); padding: 12px; line-height: 1.8; }
.trace-window { color: var(--muted); font-size: 13px; }
.trace-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.trace-actions button { font-size: 13px; padding: 8px 12px; }
.trace-pin { border: 2px solid white; border-radius: 50%; color: white; font: bold 14px/24px Arial, sans-serif; text-align: center; box-shadow: 0 1px 5px #0005; }
.trace-pin.pickup { background: #15803d; }
.trace-pin.dropoff { background: #121a15; }
.trace-pin.driver, .fraud-map .legend.driver { background: #eb0045; }
.fraud-map .legend.dropoff { background: #121a15; }
.trace-points { margin-top: 16px; }
.trace-google { padding: 14px; border: 1px solid var(--brand-border); border-radius: var(--radius-sm); background: var(--panel-soft); }
.trace-google h4 { margin-top: 0; }
.trace-google p { font-size: 13px; line-height: 1.8; color: var(--muted); }
.trace-google-links { display: flex; flex-wrap: wrap; gap: 8px; max-height: 240px; overflow: auto; }
.trace-google-links a { display: grid; gap: 5px; padding: 10px 14px; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; }
.trace-google-links a:hover { border-color: var(--brand); }
.trace-google-links small { font-size: 11px; color: var(--muted); }
.trace-points summary { cursor: pointer; padding: 10px; font-weight: 700; }
.trace-table-wrap { overflow: auto; max-height: 300px; }
.trace-points table { width: 100%; font-size: 12px; border-collapse: collapse; }
.trace-points th, .trace-points td { padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: start; }
.driver-trace-map .leaflet-popup-content { font-family: inherit; text-align: start; direction: rtl; line-height: 1.8; }
[dir="ltr"] .driver-trace-map .leaflet-popup-content { direction: ltr; }
.driver-trace-map .leaflet-control-attribution { font: 11px/1.5 Arial, sans-serif; }
@media (max-width: 600px) { .driver-trace-map { height: 360px; } }

/* ---------- decisions ---------- */

.support-actions {
  display: grid;
  gap: 10px;
  background: var(--actions-bg);
  border: 1px solid var(--actions-border);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.readonly-note {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.readonly-note strong {
  display: block;
  margin-bottom: 6px;
}

.readonly-note p {
  margin: 0;
  color: var(--muted);
}

.review-note {
  margin: 0;
}

.decision-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.decision-buttons button {
  flex: 1 1 140px;
}

.checklist,
.rules-list,
.timeline {
  display: grid;
  gap: 10px;
}

.checklist div,
.rules-list article,
.timeline article,
.official-trip div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px;
}

.rules-list article {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
}

.rules-list article span {
  font-weight: 900;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
}

.rules-list article p,
.timeline article p,
.official-trip p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.official-trip div {
  display: grid;
  gap: 6px;
}

.official-trip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.timeline article {
  border-inline-start: 3px solid var(--brand);
}

.timeline time,
.timeline small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

/* ---------- orders tables ---------- */

.orders-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 16px;
}

.orders-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.orders-tools input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--panel-soft);
}

.orders-tools .export-btn {
  flex: 0 0 auto;
}

.orders-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  max-height: calc(100vh - 300px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.orders-table {
  width: 100%;
  min-width: 1050px;
  border-collapse: collapse;
  text-align: start;
}

.mobile-back {
  display: none;
  margin-bottom: 12px;
}

.orders-table th,
.orders-table td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.orders-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--brand-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 1px 0 var(--line);
}

.orders-table tbody tr:last-child td {
  border-bottom: 0;
}

.orders-table tbody tr:nth-child(even) {
  background: var(--zebra);
}

.orders-table tbody tr:hover {
  background: var(--brand-soft);
}

.orders-table td strong,
.orders-table td small {
  display: block;
}

.orders-table td small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.order-id,
.coordinates {
  direction: ltr;
  text-align: right;
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
}

html[dir="ltr"] .order-id,
html[dir="ltr"] .coordinates {
  text-align: left;
}

.monitoring-pill,
.clear-result,
.actor-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.monitoring-pill.active {
  background: var(--amber-soft);
  color: var(--amber);
}

.monitoring-pill.completed,
.clear-result {
  background: var(--neutral-soft);
  color: var(--muted);
}

.analysis-sync {
  margin-top: 0.35rem;
}

.analysis-sync.stale {
  color: var(--amber);
}

.confirmation-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.28rem 0.68rem;
  border-radius: 999px;
  font-weight: 700;
  white-space: nowrap;
}

.confirmation-pill.confirmed {
  color: var(--red);
  background: var(--red-soft);
  border: 1px solid color-mix(in srgb, var(--red) 34%, transparent);
}

.confirmation-pill.not-confirmed {
  color: var(--muted);
  background: var(--neutral-soft);
  border: 1px solid var(--line);
}

.metric-number {
  font-variant-numeric: tabular-nums;
}

.danger-text {
  color: #d92d20;
}

.actor-pill.driver {
  background: var(--red-soft);
  color: var(--red);
}

.actor-pill.client {
  background: var(--amber-soft);
  color: var(--amber);
}

.actor-pill.system,
.actor-pill.unknown {
  background: var(--neutral-soft);
  color: var(--muted);
}

.orders-empty {
  padding: 36px !important;
  text-align: center;
  color: var(--muted);
}

pre {
  white-space: pre-wrap;
  direction: ltr;
  text-align: left;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
}

/* ---------- stats tab ---------- */

.stats-heroes {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 14px;
}

.stat-tile span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.stat-tile strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.stat-tile.danger strong {
  color: var(--red);
}

.employee-performance-panel { margin-top: 14px; }
.employee-performance-panel h3 { margin: 0 0 5px; }
.employee-performance-panel .panel-head { align-items: flex-start; }
.employee-performance-totals { display:flex; gap:10px; flex-wrap:wrap; }
.employee-performance-totals > span { min-width:145px; padding:10px 12px; border:1px solid var(--line); border-radius:12px; background:var(--panel-soft); }
.employee-performance-totals small, .employee-performance-totals strong { display:block; }
.employee-performance-totals strong { margin-top:4px; font-size:21px; }
.money-value { display:block; direction:ltr; text-align:start; white-space:nowrap; }
.employee-performance-panel td small { display:block; margin-top:4px; }

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

.chart-panel h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.chart-host svg {
  display: block;
  width: 100%;
  height: auto;
}

.c-bar {
  fill: var(--brand);
  cursor: default;
  transition: fill 0.14s ease;
}

.c-bar:hover {
  fill: var(--brand-dark);
}

.c-grid {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 3 4;
}

.c-axis {
  stroke: var(--line);
  stroke-width: 1.5;
}

.c-tick {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
}

.c-value {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 800;
  text-anchor: middle;
}

.hbars {
  display: grid;
  gap: 10px;
}

.hbar-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 10px;
}

.hbar-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.hbar-track {
  height: 12px;
  border-radius: 999px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  overflow: hidden;
}

.hbar-track i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
  min-width: 2px;
}

.hbar-row b {
  font-variant-numeric: tabular-nums;
  text-align: end;
}

.activity-feed {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.activity-feed article {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.activity-feed strong {
  display: block;
  font-size: 13px;
}

.activity-feed small {
  color: var(--muted);
  font-size: 11px;
}

.activity-feed time {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.chart-tip {
  position: fixed;
  z-index: 95;
  pointer-events: none;
  background: var(--ink);
  color: var(--bg);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: var(--shadow);
  max-width: 260px;
}

/* ---------- users tab ---------- */

.users-create {
  margin-bottom: 14px;
}

.users-create h3 {
  margin: 0 0 12px;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto;
  gap: 10px;
  align-items: center;
}

.user-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
  font: inherit;
  font-weight: 700;
}

select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 139, 74, 0.2);
}

.role-select {
  min-height: 36px;
  padding: 6px 8px;
  font-size: 13px;
}

.pill.role-owner {
  background: var(--red-soft);
  color: var(--red);
}

.pill.role-admin {
  background: var(--brand-soft);
  color: var(--brand-dark);
}

.pill.role-viewer {
  background: var(--neutral-soft);
  color: var(--muted);
}

.pill.user-on {
  background: var(--green-soft);
  color: var(--green);
}

.pill.user-off {
  background: var(--neutral-soft);
  color: var(--muted);
}

.user-inactive td {
  opacity: 0.55;
}

.user-actions {
  display: flex;
  gap: 6px;
}

.qa-wide {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}

.reset-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.reset-row input {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 13px;
}

.reset-row button {
  min-height: 36px;
  padding: 7px 12px;
  font-size: 13px;
}

.users-table td small {
  white-space: normal;
}

/* ---------- deduction settings ---------- */

.settings-panel {
  max-width: 820px;
}

.settings-panel .panel-head {
  align-items: flex-start;
}

.settings-panel h3 {
  margin: 0 0 5px;
}

.settings-form {
  display: flex;
  align-items: end;
  gap: 12px;
  margin-top: 24px;
}

.settings-form label {
  display: grid;
  gap: 7px;
  min-width: 260px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.percentage-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  overflow: hidden;
}

.percentage-field input {
  border: 0;
  box-shadow: none;
  min-width: 0;
}

.percentage-field b {
  padding-inline: 14px;
  color: var(--navy);
  font-size: 16px;
}

.settings-note {
  margin: 20px 0 0;
  padding: 14px 16px;
  border-inline-start: 4px solid var(--info);
  border-radius: var(--radius-sm);
  background: var(--info-soft);
  color: var(--ink);
  line-height: 1.8;
}

.deduction-card {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 12px 0;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--yellow);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

.deduction-card.committed {
  border-inline-start-color: var(--green);
}

.deduction-card div {
  display: grid;
  gap: 3px;
}

.deduction-card div:last-child {
  text-align: end;
}

.deduction-card span,
.deduction-card small {
  color: var(--muted);
  font-size: 12px;
}

/* ---------- scrollbars (WebKit) ---------- */

.case-queue::-webkit-scrollbar,
.orders-table-wrap::-webkit-scrollbar,
.drawer-body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.case-queue::-webkit-scrollbar-thumb,
.orders-table-wrap::-webkit-scrollbar-thumb,
.drawer-body::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 999px;
}

.case-queue::-webkit-scrollbar-track,
.orders-table-wrap::-webkit-scrollbar-track,
.drawer-body::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- responsive ---------- */

@media (max-width: 1120px) {
  .desk-grid {
    grid-template-columns: 1fr;
  }

  .desk-grid:not(.detail-open) .case-details {
    display: none;
  }

  .desk-grid.detail-open .queue-panel {
    display: none;
  }

  .desk-grid.detail-open .case-details {
    display: block;
  }

  .mobile-back {
    display: inline-flex;
  }

  .case-queue {
    max-height: none;
  }

  .queue-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .settings-form,
  .deduction-card {
    align-items: stretch;
    flex-direction: column;
  }

  .settings-form label {
    min-width: 0;
  }

  .deduction-card div:last-child {
    text-align: start;
  }
}

@media (max-width: 1120px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }

  .stats-heroes {
    grid-template-columns: repeat(2, 1fr);
  }

  .user-form {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 780px) {
  .login-view,
  .desk-view {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 25vh;
    padding: 24px;
  }

  .login-visual h1 {
    margin-block: 6px;
    font-size: 30px;
  }

  .login-visual p:last-child {
    font-size: 15px;
  }

  .login-form {
    align-self: start;
    margin-block: 18px;
    padding: 22px;
  }

  .rail {
    position: sticky;
    z-index: 45;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: 0 5px 18px rgba(5, 20, 10, 0.2);
  }

  .rail-top {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1;
  }

  .brand {
    margin: 0;
    min-width: 0;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }

  .brand-mark img {
    width: 44px;
  }

  .brand .eyebrow {
    display: none;
  }

  .brand h1 {
    font-size: 15px;
    white-space: nowrap;
  }

  .rail nav {
    position: fixed;
    z-index: 50;
    inset-inline: 0;
    bottom: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 2px;
    padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--panel) 94%, transparent);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(12, 35, 20, 0.12);
    backdrop-filter: blur(14px);
  }

  .rail nav .nav-btn {
    color: var(--ink);
    min-width: 0;
    font-size: 9px;
  }

  .rail nav .nav-btn span {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.3;
    text-align: center;
  }

  .rail nav .nav-btn svg {
    color: var(--brand-dark);
  }

  .nav-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 58px;
    padding: 5px 2px;
    border: 0;
    border-radius: 10px;
    font-size: 10px;
  }

  .nav-btn svg {
    display: block;
    width: 20px;
    height: 20px;
  }

  .rail-bottom {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .user-chip {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    border-radius: 999px;
  }

  .user-avatar {
    width: 34px;
    height: 34px;
  }

  .user-chip-text {
    display: none;
  }

  #logoutBtn {
    width: 40px;
    min-height: 40px;
    padding: 0;
  }

  #logoutBtn span {
    display: none;
  }

  .workspace {
    padding: 14px 12px calc(86px + env(safe-area-inset-bottom));
  }

  .topbar {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
    margin-bottom: 14px;
  }

  .topbar h2 {
    font-size: 21px;
  }

  .case-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    width: 100%;
    gap: 6px;
  }

  .topbar-actions button {
    min-width: 0;
    padding-inline: 8px;
    font-size: 12px;
  }

  .topbar-actions .icon-only {
    width: auto;
  }

  .risk-score {
    align-self: flex-start;
  }

  .detail-tabs {
    overflow-x: auto;
  }

  .view-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: -12px;
    padding-inline: 12px;
    padding-bottom: 4px;
    scrollbar-width: none;
    scroll-snap-type: inline proximity;
  }

  .view-chips::-webkit-scrollbar {
    display: none;
  }

  .view-chip {
    flex: none;
    scroll-snap-align: start;
  }

  .queue-panel,
  .case-details,
  .panel,
  .orders-panel {
    padding: 13px;
  }

  .case-details {
    scroll-margin-top: 66px;
  }

  .orders-table-wrap {
    max-height: none;
    overflow: visible;
    border: 0;
  }

  .orders-table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .orders-table thead {
    display: none;
  }

  .orders-table tbody {
    display: grid;
    gap: 10px;
  }

  .orders-table tbody tr {
    display: grid;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-soft);
  }

  .orders-table tbody tr:nth-child(even),
  .orders-table tbody tr:hover {
    background: var(--panel);
  }

  .orders-table td {
    display: grid;
    grid-template-columns: minmax(90px, 36%) minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 10px 11px;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  .orders-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
  }

  .orders-table td:last-child {
    border-bottom: 0;
  }

  .orders-empty {
    display: block !important;
  }

  .orders-empty::before {
    display: none;
  }

  .order-id,
  .coordinates {
    text-align: start;
  }

  .user-form {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .user-actions,
  .reset-row {
    flex-wrap: wrap;
  }

  .drawer {
    width: min(100%, 430px);
  }

  .summary-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .toasts {
    right: 12px;
    left: 12px;
    bottom: 12px;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .orders-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .orders-tools .export-btn {
    width: 100%;
  }

  .topbar-actions #helpBtn span,
  .topbar-actions #refreshBtn span {
    display: none;
  }

  .topbar-actions {
    grid-template-columns: 1fr 48px 48px 48px;
  }

  .pagination {
    flex-wrap: wrap;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- print (case report) ---------- */

@media print {
  body {
    background: #fff;
  }

  .rail,
  .topbar-actions,
  .view-chips,
  .queue-panel,
  .toasts,
  .modal-backdrop,
  .drawer-backdrop,
  .decision-buttons,
  .detail-tabs,
  #printCaseBtn,
  .copy-btn {
    display: none !important;
  }

  .desk-view,
  .desk-grid {
    display: block;
  }

  .workspace {
    padding: 0;
  }

  .case-details {
    box-shadow: none;
    border: 0;
    padding: 0;
  }

  .risk-score {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
