/* ============================================================
   K3 HVAC Maintenance Management System
   Design system & global styles
   ============================================================ */

/* Fonts: Inter for EN, IBM Plex Sans Arabic for AR */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

:root {
  /* === Brand colors (from K3 letterhead/logo) === */
  --brand:        #1ABCB0;
  --brand-dark:   #0E8A82;
  --brand-darker: #0a6b65;
  --brand-light:  #D9F2F0;
  --brand-tint:   #F0FAF9;

  /* === Neutrals === */
  --bg:            #F6F8FA;
  --surface:       #FFFFFF;
  --surface-2:     #FAFBFC;
  --border:        #E4E8EB;
  --border-strong: #C9CFD3;

  /* === Text === */
  --text:        #16222B;
  --text-muted:  #5A6B75;
  --text-faint:  #94A3AB;
  --text-invert: #FFFFFF;

  /* === Semantic === */
  --success:       #10B981;
  --success-bg:    #ECFDF5;
  --warning:       #F59E0B;
  --warning-bg:    #FFFBEB;
  --danger:        #EF4444;
  --danger-bg:     #FEF2F2;
  --info:          #3B82F6;
  --info-bg:       #EFF6FF;

  /* === Status colors (Job Card lifecycle) === */
  --status-new:        #6B7280;
  --status-assigned:   #3B82F6;
  --status-progress:   #F59E0B;
  --status-onhold:     #EF4444;
  --status-completed:  #10B981;
  --status-invoiced:   #1ABCB0;
  --status-closed:     #94A3AB;

  /* === Spacing scale === */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* === Radii === */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 12px;

  /* === Shadows === */
  --shadow-sm: 0 1px 2px rgba(16,34,43,.06), 0 1px 1px rgba(16,34,43,.04);
  --shadow-md: 0 2px 4px rgba(16,34,43,.06), 0 4px 8px rgba(16,34,43,.06);
  --shadow-lg: 0 8px 16px rgba(16,34,43,.08), 0 16px 32px rgba(16,34,43,.06);
  --shadow-focus: 0 0 0 3px rgba(26, 188, 176, 0.25);

  /* === Typography === */
  --font-en: 'Inter', system-ui, -apple-system, sans-serif;
  --font-ar: 'IBM Plex Sans Arabic', 'Tahoma', sans-serif;
  --font-mono: 'SF Mono', 'Consolas', 'Monaco', monospace;

  /* === Z-index === */
  --z-sidebar: 10;
  --z-topbar: 20;
  --z-dropdown: 50;
  --z-modal: 100;
  --z-toast: 200;

  /* === Layout === */
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;
}

/* === Reset === */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-en);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
html[lang="ar"] body { font-family: var(--font-ar); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
table { border-collapse: collapse; width: 100%; }
h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; }

/* === RTL global support === */
html[dir="rtl"] { direction: rtl; }
html[dir="rtl"] body { text-align: right; }

/* ============================================================
   APP SHELL
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
}
html[dir="rtl"] .app-shell {
  grid-template-columns: 1fr var(--sidebar-w);
  grid-template-areas:
    "topbar sidebar"
    "main sidebar";
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  grid-area: sidebar;
  background: linear-gradient(180deg, #0E8A82 0%, #0a6b65 100%);
  color: white;
  display: flex;
  flex-direction: column;
  z-index: var(--z-sidebar);
  overflow-y: auto;
}
.sidebar-brand {
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border-bottom: 1px solid rgba(255,255,255,.1);
  min-height: var(--topbar-h);
}
.sidebar-brand-icon {
  width: 32px; height: 32px;
  background: white;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.5px;
}
.sidebar-brand-text {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.2px;
}
.sidebar-brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}
.sidebar-nav {
  padding: var(--sp-3) var(--sp-2);
  flex: 1;
}
.sidebar-section-label {
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,.5);
  font-weight: 600;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  color: rgba(255,255,255,.85);
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 500;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: start;
  transition: background .12s, color .12s;
}
.sidebar-link:hover {
  background: rgba(255,255,255,.08);
  color: white;
  text-decoration: none;
}
.sidebar-link.is-active {
  background: rgba(255,255,255,.15);
  color: white;
  box-shadow: inset 3px 0 0 var(--brand);
}
html[dir="rtl"] .sidebar-link.is-active {
  box-shadow: inset -3px 0 0 var(--brand);
}
.sidebar-link svg {
  width: 18px; height: 18px;
  flex-shrink: 0;
  stroke-width: 1.8;
}
.sidebar-foot {
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: 11px;
  color: rgba(255,255,255,.5);
}

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar {
  grid-area: topbar;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--sp-6);
  gap: var(--sp-4);
  z-index: var(--z-topbar);
}
.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.topbar-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.topbar-search {
  position: relative;
  width: 280px;
}
.topbar-search input {
  width: 100%;
  padding: 7px var(--sp-3) 7px 32px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  font-size: 13px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
html[dir="rtl"] .topbar-search input {
  padding: 7px 32px 7px var(--sp-3);
}
.topbar-search input:focus {
  background: white;
  border-color: var(--brand);
  box-shadow: var(--shadow-focus);
}
.topbar-search svg {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--text-faint);
  pointer-events: none;
}

.lang-switch {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 2px;
}
.lang-switch button {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  letter-spacing: 0.3px;
}
.lang-switch button.is-active {
  background: var(--brand);
  color: white;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px var(--sp-2);
  border-radius: var(--r-md);
  cursor: pointer;
  border: 0;
  background: transparent;
}
.user-chip:hover { background: var(--bg); }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: white;
  display: grid; place-items: center;
  font-weight: 600;
  font-size: 12px;
}
.user-info { text-align: start; line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */

.main {
  grid-area: main;
  overflow-y: auto;
  padding: var(--sp-6) var(--sp-8);
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--sp-6);
  gap: var(--sp-4);
  flex-wrap: wrap;
}
.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin-bottom: var(--sp-1);
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}
.page-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
}
.card-body { padding: var(--sp-5); }
.card-body.flush { padding: 0; }
.card-footer {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ============================================================
   KPI TILES (for dashboard)
   ============================================================ */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  inset-inline-start: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--brand);
}
.kpi.is-warning::before { background: var(--warning); }
.kpi.is-danger::before  { background: var(--danger); }
.kpi.is-success::before { background: var(--success); }

.kpi-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}
.kpi-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.kpi-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--sp-2);
}
.kpi-trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--r-sm);
}
.kpi-trend.up { color: var(--success); background: var(--success-bg); }
.kpi-trend.down { color: var(--danger); background: var(--danger-bg); }

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 7px 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  background: white;
  color: var(--text);
  border-color: var(--border);
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; stroke-width: 2; }

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

.btn-secondary {
  background: var(--bg);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}
.btn-danger:hover { background: #c83232; }

.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 10px 18px; font-size: 14px; }

.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  border-radius: var(--r-md);
}

/* ============================================================
   FORMS
   ============================================================ */

.form-row {
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(2, 1fr);
  margin-bottom: var(--sp-4);
}
.form-row.col-1 { grid-template-columns: 1fr; }
.form-row.col-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.col-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) { .form-row { grid-template-columns: 1fr !important; } }

.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field.full-row { grid-column: 1 / -1; }
.form-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
}
.form-label .req { color: var(--danger); margin-inline-start: 2px; }
.form-help { font-size: 11.5px; color: var(--text-muted); }
.form-error { font-size: 11.5px; color: var(--danger); margin-top: 2px; }

.input, .select, .textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: white;
  font-size: 13px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  width: 100%;
  color: var(--text);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: var(--shadow-focus);
}
.input.has-error, .select.has-error, .textarea.has-error {
  border-color: var(--danger);
}
.textarea { resize: vertical; min-height: 70px; font-family: inherit; }
.input[readonly] { background: var(--surface-2); color: var(--text-muted); }

.input-group {
  display: flex;
  align-items: stretch;
}
.input-group .input { border-radius: 0; }
.input-group > :first-child { border-start-start-radius: var(--r-md); border-end-start-radius: var(--r-md); }
.input-group > :last-child  { border-start-end-radius: var(--r-md); border-end-end-radius: var(--r-md); }
.input-addon {
  display: grid; place-items: center;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.input-group .input + .input-addon { border-inline-start: 0; }
.input-group .input-addon + .input { border-inline-start: 0; }

.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  font-size: 13px;
}

/* ============================================================
   TABLES
   ============================================================ */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.data-table {
  width: 100%;
  font-size: 13px;
}
.data-table thead th {
  text-align: start;
  padding: 10px var(--sp-4);
  background: var(--surface-2);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 11px var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: end; font-variant-numeric: tabular-nums; }
.data-table .actions { text-align: end; white-space: nowrap; }
.data-table .row-link { color: var(--brand-dark); font-weight: 500; cursor: pointer; }
.data-table .row-link:hover { text-decoration: underline; }
.data-table tr.is-clickable { cursor: pointer; }

.table-toolbar {
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.table-toolbar .input { max-width: 280px; }

.empty-state {
  padding: var(--sp-12) var(--sp-6);
  text-align: center;
  color: var(--text-muted);
}
.empty-state .empty-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: var(--sp-1); }
.empty-state .empty-text { font-size: 13px; }

/* ============================================================
   BADGES & STATUS PILLS
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  background: var(--bg);
  color: var(--text-muted);
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.badge.no-dot::before { display: none; }

.badge.status-new        { color: var(--status-new);       background: #F1F3F5; }
.badge.status-assigned   { color: var(--status-assigned);  background: #EFF6FF; }
.badge.status-progress   { color: var(--status-progress);  background: var(--warning-bg); }
.badge.status-onhold     { color: var(--status-onhold);    background: var(--danger-bg); }
.badge.status-completed  { color: var(--status-completed); background: var(--success-bg); }
.badge.status-invoiced   { color: var(--brand-dark);       background: var(--brand-light); }
.badge.status-closed     { color: var(--status-closed);    background: #F1F3F5; }
.badge.status-paid       { color: var(--success);          background: var(--success-bg); }
.badge.status-pending    { color: var(--warning);          background: var(--warning-bg); }
.badge.status-overdue    { color: var(--danger);           background: var(--danger-bg); }
.badge.priority-high     { color: var(--danger);           background: var(--danger-bg); }
.badge.priority-normal   { color: var(--text-muted);       background: #F1F3F5; }
.badge.priority-low      { color: var(--info);             background: var(--info-bg); }

/* ============================================================
   TABS
   ============================================================ */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-5);
}
.tab {
  padding: var(--sp-3) var(--sp-4);
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .12s;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  color: var(--brand-dark);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

/* ============================================================
   MODAL / DRAWER
   ============================================================ */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 30, 38, 0.5);
  backdrop-filter: blur(2px);
  z-index: var(--z-modal);
  display: grid; place-items: center;
  animation: fadeIn .15s;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  animation: slideUp .2s;
}
.modal.modal-lg { width: min(900px, calc(100vw - 32px)); }
.modal.modal-xl { width: min(1100px, calc(100vw - 32px)); }
.modal-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  border: 0; background: transparent;
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--text-muted);
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body {
  padding: var(--sp-5);
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   TOASTS
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.toast {
  background: var(--text);
  color: white;
  padding: 10px var(--sp-4);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  min-width: 240px;
  animation: slideInToast .25s;
}
.toast.is-success { background: var(--success); }
.toast.is-warning { background: var(--warning); color: #5b3a00; }
.toast.is-error   { background: var(--danger); }

@keyframes slideInToast {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
html[dir="rtl"] @keyframes slideInToast {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 480px;
  background: var(--surface);
}
html[dir="rtl"] .login-shell { grid-template-columns: 480px 1fr; }
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}
.login-aside {
  background:
    radial-gradient(at 20% 100%, rgba(26,188,176,0.4) 0%, transparent 50%),
    radial-gradient(at 80% 0%, rgba(14,138,130,0.3) 0%, transparent 50%),
    linear-gradient(135deg, #0E8A82 0%, #0a6b65 100%);
  color: white;
  padding: var(--sp-12);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-aside::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.03) 75%, rgba(255,255,255,0.03)),
    linear-gradient(45deg, rgba(255,255,255,0.03) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.03) 75%, rgba(255,255,255,0.03));
  background-size: 60px 60px;
  background-position: 0 0, 30px 30px;
  pointer-events: none;
}
.login-aside-content { position: relative; z-index: 1; max-width: 420px; }
.login-aside-logo {
  width: 60px; height: 60px;
  background: white;
  border-radius: var(--r-lg);
  display: grid; place-items: center;
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -1px;
  margin-bottom: var(--sp-6);
  box-shadow: var(--shadow-lg);
}
.login-aside h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1.15;
  margin-bottom: var(--sp-4);
}
.login-aside p {
  font-size: 15px;
  color: rgba(255,255,255,0.85);
  line-height: 1.55;
}
.login-aside-foot { position: relative; z-index: 1; font-size: 12px; color: rgba(255,255,255,0.6); }

.login-form-side {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--sp-12) var(--sp-10);
  position: relative;
}
.login-form-side .login-lang {
  position: absolute;
  top: var(--sp-5);
  inset-inline-end: var(--sp-5);
}
.login-form {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}
.login-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin-bottom: var(--sp-1);
}
.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: var(--sp-8);
}
.login-form .form-field { margin-bottom: var(--sp-4); }
.login-hint {
  margin-top: var(--sp-5);
  padding: var(--sp-3) var(--sp-4);
  background: var(--brand-tint);
  border: 1px solid var(--brand-light);
  border-radius: var(--r-md);
  font-size: 12px;
  color: var(--brand-darker);
}
.login-hint strong { display: block; margin-bottom: 2px; font-weight: 600; }
.login-hint code {
  background: white;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11.5px;
  border: 1px solid var(--brand-light);
}

/* ============================================================
   DASHBOARD SECTION HELPERS
   ============================================================ */

.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-5);
}
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }

.activity-list {
  list-style: none;
  margin: 0; padding: 0;
}
.activity-item {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: 0; }
.activity-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--brand-tint);
  color: var(--brand-dark);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.activity-icon svg { width: 14px; height: 14px; }
.activity-body { flex: 1; min-width: 0; }
.activity-text { color: var(--text); }
.activity-text strong { font-weight: 600; }
.activity-time { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ============================================================
   JOB CARD KANBAN
   ============================================================ */

.kanban {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: var(--sp-3);
  overflow-x: auto;
  padding-bottom: var(--sp-4);
}
.kanban-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  min-height: 200px;
}
.kanban-col-header {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}
.kanban-col-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--text);
}
.kanban-col-body {
  padding: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
}
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  cursor: pointer;
  transition: border-color .12s, transform .12s;
  font-size: 12.5px;
}
.kanban-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.kanban-card-id { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.kanban-card-title { font-weight: 500; margin: 4px 0; }
.kanban-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--sp-2);
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================================
   DETAIL VIEW (Job Card / Customer detail)
   ============================================================ */

.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--sp-5);
}
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }

.kv-list {
  display: grid;
  grid-template-columns: 130px 1fr;
  row-gap: 10px;
  column-gap: var(--sp-4);
  font-size: 13px;
}
.kv-list dt { color: var(--text-muted); }
.kv-list dd { margin: 0; font-weight: 500; }

.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}

/* ============================================================
   INVOICE / DOCUMENT PRINT VIEW
   ============================================================ */

.doc-page {
  background: white;
  width: 210mm;
  min-height: 297mm;
  margin: var(--sp-4) auto;
  box-shadow: var(--shadow-md);
  padding: 18mm 16mm;
  font-size: 12px;
  position: relative;
}
.doc-letterhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 2px solid var(--brand);
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-6);
}
.doc-letterhead-en { text-align: start; }
.doc-letterhead-ar { text-align: end; font-family: var(--font-ar); }
.doc-company-name { font-size: 18px; font-weight: 700; color: var(--brand-dark); letter-spacing: -0.4px; }
.doc-company-tag { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.doc-logo {
  width: 60px; height: 60px;
  border-radius: var(--r-md);
  background: var(--brand-dark);
  color: white;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -1px;
}
.doc-title-bar {
  background: var(--brand-dark);
  color: white;
  text-align: center;
  padding: 6px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 1px;
  margin-bottom: var(--sp-5);
  text-transform: uppercase;
}
.doc-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  font-size: 11px;
}
.doc-meta-grid .kv { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed var(--border); }
.doc-meta-grid .kv .label { color: var(--text-muted); font-weight: 500; }

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  margin-bottom: var(--sp-5);
}
.doc-table th {
  background: var(--brand-dark);
  color: white;
  text-align: start;
  padding: 6px 8px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
}
.doc-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.doc-table .num { text-align: end; font-variant-numeric: tabular-nums; }

.doc-totals { margin-inline-start: auto; width: 280px; font-size: 12px; }
.doc-totals .row {
  display: flex;
  justify-content: space-between;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
}
.doc-totals .row.total {
  background: var(--brand-light);
  font-weight: 700;
  font-size: 13px;
  color: var(--brand-darker);
  border-bottom: 0;
}

.doc-foot {
  margin-top: var(--sp-8);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
  font-size: 10px;
  color: var(--text-muted);
}
.doc-sig {
  border-top: 1px solid var(--text);
  margin-top: var(--sp-10);
  padding-top: 4px;
  text-align: center;
}

@media print {
  .topbar, .sidebar, .page-header, .page-actions, .modal-backdrop, .toast-container {
    display: none !important;
  }
  .app-shell {
    display: block;
    height: auto;
  }
  .main {
    padding: 0;
    overflow: visible;
  }
  .doc-page {
    box-shadow: none;
    margin: 0;
    width: 100%;
    min-height: auto;
  }
  body { background: white; }
}

/* ============================================================
   UTILITIES
   ============================================================ */

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-5 { margin-top: var(--sp-5); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 16px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.text-mono { font-family: var(--font-mono); }
.text-end { text-align: end; }
.text-center { text-align: center; }

.divider { height: 1px; background: var(--border); margin: var(--sp-4) 0; }

.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: white;
  min-height: 36px;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--brand-light);
  color: var(--brand-darker);
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-weight: 500;
}

/* ============================================================
   SETTINGS LAYOUT
   ============================================================ */

.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--sp-6);
}
@media (max-width: 900px) { .settings-layout { grid-template-columns: 1fr; } }

.settings-nav {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-2);
  height: fit-content;
}
.settings-nav button {
  display: block;
  width: 100%;
  text-align: start;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.settings-nav button:hover { background: var(--bg); color: var(--text); }
.settings-nav button.is-active {
  background: var(--brand-tint);
  color: var(--brand-darker);
  font-weight: 600;
}

/* ============================================================
   TIMELINE
   ============================================================ */
.timeline {
  list-style: none;
  margin: 0; padding: 0;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  inset-inline-start: 11px;
  top: 6px; bottom: 6px;
  width: 2px;
  background: var(--border);
}
.timeline li {
  position: relative;
  padding-inline-start: 32px;
  padding-bottom: var(--sp-4);
  font-size: 13px;
}
.timeline li::before {
  content: "";
  position: absolute;
  inset-inline-start: 6px; top: 3px;
  width: 12px; height: 12px;
  background: var(--brand);
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--border);
}
.timeline-time { font-size: 11px; color: var(--text-muted); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  html[dir="rtl"] .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar {
    position: fixed;
    inset-inline-start: 0;
    top: 0; bottom: 0;
    width: 240px;
    transform: translateX(-100%);
    transition: transform .2s;
  }
  html[dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.is-open { transform: translateX(0); }
  .main { padding: var(--sp-4); }
  .topbar-search { display: none; }
}
.menu-toggle { display: none; }
@media (max-width: 768px) { .menu-toggle { display: inline-flex; } }

/* ============================================================
   CUSTOMER SERVICE INTAKE SCREEN
   ============================================================ */
.intake-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 1100px) {
  .intake-grid { grid-template-columns: 1fr; }
}

.intake-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.intake-section:last-child { border-bottom: 0; }

.intake-step {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
}
.intake-step .step-num {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-size: 12px;
  font-weight: 700;
}
.intake-step .optional-tag {
  margin-inline-start: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  background: var(--surface-alt);
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.phone-icon { font-size: 18px; }

/* Customer search results */
.intake-search-results {
  margin-top: 8px;
  display: flex; flex-direction: column; gap: 6px;
}
.cust-result {
  text-align: start;
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.1s;
}
.cust-result:hover {
  background: var(--brand-tint);
  border-color: var(--brand-light);
}
.cust-result-line1 {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.cust-result-line2 {
  display: flex; gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}
.no-results {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Picked customer card */
.intake-customer-card {
  background: var(--brand-tint);
  border: 1.5px solid var(--brand-light);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.intake-customer-card .cust-name {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 600;
}
.intake-customer-card .cust-ar {
  font-size: 14px; margin-top: 2px;
  color: var(--text);
  font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif;
}
.intake-customer-card .cust-meta {
  display: flex; flex-wrap: wrap; gap: 12px;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.intake-customer-card .cust-contracts {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--brand-light);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.label-tag {
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--brand-darker);
  letter-spacing: 0.5px;
  margin-inline-end: 4px;
}
.contract-pill {
  background: white !important;
  border: 1px solid var(--brand-light);
  color: var(--brand-darker);
  font-weight: 600;
}

/* Problem-type chips */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px;
}
.chip {
  padding: 8px 12px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 13px;
  text-align: start;
  transition: all 0.1s;
  display: flex; flex-direction: column; gap: 2px;
}
.chip:hover {
  border-color: var(--brand-light);
}
.chip.is-on {
  background: var(--brand-tint);
  border-color: var(--brand);
  color: var(--brand-darker);
}
.chip.is-on .chip-en { font-weight: 600; }
.chip-en { font-size: 13px; }
.chip-ar {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif;
}
.chip.is-on .chip-ar { color: var(--brand-darker); opacity: 0.85; }

/* Technician picker grid */
.tech-pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.tech-card {
  padding: 10px 12px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  text-align: start;
  transition: all 0.1s;
}
.tech-card:hover { border-color: var(--brand-light); }
.tech-card.is-on {
  background: var(--brand-tint);
  border-color: var(--brand);
}
.tech-card.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.tech-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.tech-card.is-on .tech-avatar { box-shadow: 0 0 0 2px white, 0 0 0 4px var(--brand); }
.tech-info { overflow: hidden; }
.tech-name { font-weight: 600; font-size: 13px; }
.tech-skill { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tech-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
}
.tech-status.status-available { background: #d1fae5; color: #065f46; }
.tech-status.status-onsite    { background: #fef3c7; color: #92400e; }
.tech-status.status-offduty   { background: #e5e7eb; color: #6b7280; }

/* Submit bar at bottom of intake form */
.intake-submit {
  margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px;
}

/* Today's open jobs sidebar */
.mini-job-list {
  display: flex; flex-direction: column;
}
.mini-job {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  display: flex; flex-direction: column; gap: 2px;
  transition: background 0.1s;
}
.mini-job:hover { background: var(--surface-alt); }
.mini-job:last-child { border-bottom: 0; }
.mini-job-line1 {
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
}
.mini-job-line2 { font-size: 13px; font-weight: 500; }
.mini-job-line3 { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ============================================================
   ARRIVAL TIMER BANNER
   ============================================================ */
.arrival-banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px; align-items: center;
  padding: 14px 18px;
  margin: 12px 0;
  background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
  border: 1.5px solid #fdba74;
  border-radius: var(--r-md);
  box-shadow: 0 2px 4px rgba(251, 146, 60, 0.1);
}
.arrival-banner .banner-icon {
  font-size: 28px;
  animation: pulse 2s infinite;
}
.arrival-banner .banner-title {
  font-weight: 700;
  font-size: 15px;
  color: #9a3412;
}
.arrival-banner .banner-meta {
  font-size: 13px;
  color: #7c2d12;
  margin-top: 2px;
}
.arrival-banner .elapsed-clock {
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  font-weight: 700;
}
.btn-success {
  background: #16a34a;
  color: white;
}
.btn-success:hover { background: #15803d; }
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* ============================================================
   NOTIFICATIONS BELL & PANEL
   ============================================================ */
.notif-wrap {
  position: relative;
}
.notif-bell {
  position: relative;
  background: transparent;
  border: 1px solid var(--border);
  width: 38px; height: 38px;
  border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text);
  padding: 0;
}
.notif-bell:hover {
  background: var(--surface-alt);
  border-color: var(--brand-light);
}
.notif-bell svg { width: 18px; height: 18px; }
.notif-badge {
  position: absolute;
  top: -4px; inset-inline-end: -4px;
  background: #dc2626;
  color: white;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 2px solid white;
}

.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  width: 380px;
  max-height: 480px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  overflow: hidden;
  display: flex; flex-direction: column;
  z-index: 100;
}
.notif-panel-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface-alt);
}
.btn-link {
  background: transparent; border: 0;
  color: var(--brand);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}
.btn-link:hover { text-decoration: underline; }

.notif-list {
  flex: 1;
  overflow-y: auto;
}
.notif-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.notif-empty > div:first-child { margin-bottom: 8px; }

.notif-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  cursor: pointer;
  transition: background 0.1s;
}
.notif-item:hover { background: var(--surface-alt); }
.notif-item:last-child { border-bottom: 0; }
.notif-item.is-unread {
  background: var(--brand-tint);
  border-inline-start: 3px solid var(--brand);
}
.notif-kind {
  font-size: 18px;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-alt);
  flex-shrink: 0;
}
.notif-kind-arrival { background: #ffedd5; }
.notif-kind-completed { background: #d1fae5; }
.notif-kind-new_request { background: #dbeafe; }
.notif-kind-assignment { background: #fef3c7; }
.notif-text {
  font-size: 13px;
  line-height: 1.4;
}
.notif-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ============================================================
   CASH REQUESTS — lifecycle strip, line picker, customer view
   ============================================================ */

/* Lifecycle progress strip */
.lifecycle-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.ls-step {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 4px;
}
.ls-bullet {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  border: 2px solid var(--border);
  background: white;
  color: var(--text-muted);
  flex-shrink: 0;
}
.ls-label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.ls-past .ls-bullet { background: var(--brand); border-color: var(--brand); color: white; }
.ls-past .ls-label { color: var(--text); }
.ls-current .ls-bullet { background: var(--brand-tint); border-color: var(--brand); color: var(--brand-darker); box-shadow: 0 0 0 4px rgba(26, 188, 176, 0.15); }
.ls-current .ls-label { color: var(--brand-darker); font-weight: 600; }
.ls-skipped { opacity: 0.4; }
.ls-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 20px;
}
.ls-connector.ls-past { background: var(--brand); }
.ls-rejected-tag {
  margin-inline-start: auto;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fef2f2;
  color: #b91c1c;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Cash actions card body */
.cash-actions-body {
  display: flex; flex-direction: column; gap: 8px;
}

/* Customer link box on cash detail */
.cash-link-box {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--surface-alt);
  border: 1px dashed var(--border);
  border-radius: var(--r-md);
}
.cash-link-url {
  flex: 1;
  font-family: monospace;
  font-size: 12px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Cash line picker (modal) */
.cash-line-picker-list {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-alt);
}
.cash-pick-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 12px;
  background: white;
  border: 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-align: start;
  transition: background 0.1s;
  width: 100%;
}
.cash-pick-item:last-child { border-bottom: 0; }
.cash-pick-item:hover { background: var(--brand-tint); }
.cash-pick-item.is-picked { background: var(--brand-tint); border-inline-start: 3px solid var(--brand); }
.pick-en { font-weight: 500; font-size: 13px; }
.pick-ar { font-size: 11px; color: var(--text-muted); margin-top: 2px;
  font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif; }
.pick-meta { text-align: end; }
.pick-cat { font-size: 11px; color: var(--text-muted); }
.pick-price { font-weight: 600; font-size: 13px; color: var(--brand-darker); }
.cash-line-picker-qty {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  margin-top: 12px;
  background: var(--brand-tint);
  border: 1px solid var(--brand-light);
  border-radius: var(--r-md);
}

/* Customer-facing approval page (chrome=false) */
.cash-approve-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 24px;
  background: white;
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
}
.cash-approve-head {
  border-bottom: 2px solid var(--brand);
  padding-bottom: 16px; margin-bottom: 24px;
}
.cash-approve-brand {
  text-align: center;
}
.cash-approve-name {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-darker);
}
.cash-approve-name-ar {
  font-size: 18px;
  color: var(--brand-darker);
  font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif;
  margin-top: 4px;
}
.cash-approve-tag {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 8px;
}
.cash-approve-meta {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
}
.cash-approve-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.cash-approve-section h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--text);
}
.cash-approve-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cash-approve-table th, .cash-approve-table td {
  border: 1px solid var(--border);
  padding: 8px 10px;
  text-align: start;
}
.cash-approve-table th {
  background: var(--brand-tint);
  font-weight: 600;
}
.cash-approve-table .num { text-align: end; font-variant-numeric: tabular-nums; }
.cash-approve-decision {
  background: var(--brand-tint);
  border-radius: var(--r-md);
  padding: 16px;
  margin: 16px 0;
}
.cash-approve-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}
.cash-approve-buttons .btn {
  padding: 12px;
  font-size: 15px;
}
.btn-danger {
  background: #dc2626;
  color: white;
}
.btn-danger:hover { background: #b91c1c; }
.cash-approved-banner, .cash-rejected-banner {
  text-align: center;
  padding: 24px;
  border-radius: var(--r-md);
  margin: 16px 0;
}
.cash-approved-banner { background: #d1fae5; }
.cash-rejected-banner { background: #fee2e2; }
.cash-approved-banner h3, .cash-rejected-banner h3 {
  margin: 8px 0;
  font-size: 18px;
}

/* Mobile-friendly customer page */
@media (max-width: 600px) {
  .cash-approve-page { padding: 12px; }
  .cash-approve-buttons { grid-template-columns: 1fr; }
}

/* ============================================================
   ملف العميل الموسع — Documents grid
   ============================================================ */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  padding: 16px;
}
.doc-tile {
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.doc-tile:hover {
  border-color: var(--brand-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.doc-thumb {
  height: 120px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface-alt);
  overflow: hidden;
}
.doc-thumb img {
  width: 100%; height: 100%; object-fit: cover;
}
.doc-icon {
  font-size: 48px;
  opacity: 0.55;
}
.doc-meta {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}
.doc-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.doc-kind {
  display: inline-block;
  font-size: 10px;
  text-transform: uppercase;
  background: var(--brand-tint);
  color: var(--brand-darker);
  padding: 2px 6px;
  border-radius: 999px;
  margin-top: 4px;
}
.doc-size {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.doc-actions {
  display: flex; gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}
.doc-actions .btn { flex: 1; }

/* ============================================================
   FLEET — Work Groups grid + crew rows
   شبكة كروت مجموعات العمل: كل كرت يعرض الطاقم الكامل (4 أشخاص/معدات)
   ============================================================ */
.wg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  padding: 16px;
}
.wg-tile {
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
}
.wg-tile:hover { border-color: var(--brand-light); box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.wg-tile.is-inactive { opacity: 0.6; }
.wg-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.wg-name { font-weight: 700; font-size: 15px; color: var(--text); }
.wg-name-ar {
  font-size: 13px; color: var(--text-muted); margin-top: 2px;
  font-family: 'IBM Plex Sans Arabic', Tahoma, sans-serif;
}
.wg-crew { padding: 8px 14px; }
.wg-crew-row {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.wg-crew-row:last-child { border-bottom: 0; }
.wg-crew-row.is-empty { opacity: 0.45; }
.wg-crew-emoji {
  font-size: 20px;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-tint);
  border-radius: 50%;
}
.wg-crew-row.is-empty .wg-crew-emoji {
  background: var(--surface-alt);
  filter: grayscale(0.8);
}
.wg-crew-text { line-height: 1.3; }
.wg-crew-role {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.wg-crew-name { font-size: 13px; font-weight: 500; color: var(--text); }
.wg-crew-sub { font-size: 11px; color: var(--text-muted); }
.wg-notes {
  padding: 8px 14px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
}
.wg-actions {
  display: flex; gap: 4px;
  padding: 6px 8px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
}
.wg-actions .btn:first-child { flex: 1; }

/* ============================================================
   REPORTS — تخطيط، رسوم بيانية، تنبيهات
   ============================================================ */

/* تخطيط الصفحة: قائمة على اليسار + محتوى يمين */
.reports-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 900px) {
  .reports-layout { grid-template-columns: 1fr; }
}

.reports-sidebar {
  display: flex; flex-direction: column;
  gap: 4px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px;
  position: sticky; top: 16px;
}
.report-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  text-align: start;
  transition: background 0.1s;
}
.report-item:hover { background: var(--surface-alt); }
.report-item.is-active {
  background: var(--brand-tint);
  color: var(--brand-darker);
  font-weight: 600;
}
.report-emoji { font-size: 18px; }
.report-name { font-size: 13px; }

.reports-content {
  display: flex; flex-direction: column; gap: 16px;
}
.report-section { display: flex; flex-direction: column; gap: 16px; }

/* تنبيهات */
.alert-card {
  border-color: #fdba74 !important;
  background: #fff7ed;
}
.alert-card .card-header {
  background: #ffedd5;
  border-bottom-color: #fdba74;
}
.alert-card .card-title { color: #9a3412; }

/* عمود نسبة مع شريط تقدم */
.progress-cell {
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-end;
}
.progress-bar {
  width: 60px; height: 6px;
  background: var(--surface-alt);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill { height: 100%; transition: width 0.3s; }
.progress-text {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 36px;
}

/* رسوم بيانية */
.chart-bar-wrap {
  width: 100%;
  display: flex; justify-content: center;
  padding: 8px 0;
}
.chart-svg {
  width: 100%;
  max-height: 240px;
}

/* أعمدة أفقية */
.chart-hbar-wrap {
  display: flex; flex-direction: column;
  gap: 6px;
  padding: 8px 0;
}
.hbar-row {
  display: grid;
  grid-template-columns: 130px 1fr 160px;
  gap: 12px;
  align-items: center;
  padding: 4px 0;
}
.hbar-label {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hbar-track {
  height: 12px;
  background: var(--surface-alt);
  border-radius: 6px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.4s ease-out;
}
.hbar-value {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: end;
}
.hbar-secondary {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 11px;
}

/* رسم دونات */
.chart-donut-wrap {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: center;
  padding: 8px 0;
}
@media (max-width: 600px) {
  .chart-donut-wrap { grid-template-columns: 1fr; justify-items: center; }
}
.chart-donut {
  width: 160px; height: 160px;
}
.chart-legend {
  display: flex; flex-direction: column;
  gap: 6px;
}
.legend-item {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.legend-dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 3px;
}
.legend-label { color: var(--text); }
.legend-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   INTERACTIVE FORMS — Maintenance Report + Store Vouchers
   ============================================================ */

/* Maintenance Report — sections */
.mr-form { display: flex; flex-direction: column; gap: 16px; }

.mr-status-strip {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px; align-items: center;
  padding: 12px 16px;
  border-radius: var(--r-md);
  border: 1.5px solid var(--border);
  background: var(--surface-alt);
  margin-bottom: 4px;
}
.mr-status-strip.mr-status-submitted { background: #fff7ed; border-color: #fdba74; }
.mr-status-strip.mr-status-approved  { background: #d1fae5; border-color: #6ee7b7; }
.mr-status-strip.mr-status-rejected  { background: #fef2f2; border-color: #fca5a5; }
.mr-status-icon { font-size: 28px; text-align: center; }
.mr-status-label { font-weight: 700; font-size: 14px; }
.mr-status-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.mr-section {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: white;
}
.mr-section-head {
  padding: 10px 14px;
  background: var(--brand-tint);
  color: var(--brand-darker);
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--brand-light);
}
.mr-section-body {
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}

/* Complaint chips */
.mr-checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
}
.mr-chip {
  padding: 8px 12px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: 12px;
  text-align: center;
  transition: all 0.1s;
}
.mr-chip:hover { border-color: var(--brand-light); }
.mr-chip.is-on {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
  font-weight: 600;
}

/* Equipment table */
.mr-equipment-host {
  overflow-x: auto;
}
.mr-eq-table {
  font-size: 11px;
  min-width: 900px;
}
.mr-eq-table th, .mr-eq-table td {
  padding: 4px 6px !important;
}
.input-sm {
  padding: 4px 6px;
  font-size: 12px;
  height: auto;
  min-height: 28px;
}
.input-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Customer rating buttons */
.mr-rating-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}
.mr-rating-btn {
  padding: 12px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  font-weight: 600;
  text-align: center;
  transition: all 0.1s;
}
.mr-rating-btn:hover { border-color: var(--brand-light); }
.mr-rating-btn.is-on {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
}

/* Store voucher modal — items */
.sv-items-host {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-alt);
  padding: 8px;
}
.sv-detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 12px;
  background: var(--surface-alt);
  border-radius: var(--r-md);
  font-size: 13px;
}
.sv-notes-block {
  padding: 10px;
  background: var(--surface-alt);
  border-radius: var(--r-md);
  font-size: 13px;
}
.sv-audit {
  padding: 10px;
  background: var(--surface-alt);
  border-radius: var(--r-md);
}
.sv-audit > div { padding: 2px 0; }

/* ============================================================
   RBAC + Excel Import/Export
   ============================================================ */

/* جدول الصلاحيات */
.perm-table {
  font-size: 12px;
}
.perm-table .perm-mod {
  background: var(--brand-tint);
  color: var(--brand-darker);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  vertical-align: middle;
}
.perm-table input[type="checkbox"] {
  width: 16px; height: 16px;
  cursor: pointer;
}

/* شبكة Export/Import tiles */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.export-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.export-tile:hover {
  border-color: var(--brand-light);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.export-label {
  font-weight: 600;
  font-size: 14px;
}
.export-count {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ============================================================
   Users Management
   ============================================================ */
.user-avatar-sm {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand);
  color: white;
  border-radius: 50%;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.form-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 12px;
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* ============================================================
   Contract Templates Builder
   ============================================================ */
.template-code-badge {
  background: var(--brand-tint);
  color: var(--brand-darker);
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 11px;
  padding: 4px 8px;
}

/* Coverage Matrix */
.matrix-table .match-cond {
  display: inline-block;
  background: var(--bg-soft, #f1f5f9);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-family: monospace;
  margin: 1px 2px;
}

/* Coverage Tester */
.tester-result-box .decision-card {
  border: 2px solid;
  border-radius: 8px;
  padding: 12px 14px;
  background: white;
}
.decision-covered        { border-color: #10b981; background: #ecfdf5; }
.decision-chargeable     { border-color: #ef4444; background: #fef2f2; }
.decision-partially      { border-color: #f59e0b; background: #fffbeb; }
.decision-warranty_claim { border-color: #3b82f6; background: #eff6ff; }
.decision-approval       { border-color: #f59e0b; background: #fffbeb; }
.decision-not_allowed    { border-color: #6b7280; background: #f9fafb; }

.decision-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.decision-result { flex-shrink: 0; }
.decision-rule { color: var(--text-muted); font-size: 13px; }
.decision-amounts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  background: rgba(0,0,0,0.03);
  border-radius: 6px;
}
.decision-amount { text-align: center; }
.decision-amount .amount-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}
.decision-amount .amount-value {
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.decision-amount.amount-customer .amount-value { color: #ef4444; }
.decision-amount.amount-covered .amount-value { color: #10b981; }
.decision-amount.amount-claim .amount-value { color: #3b82f6; }
.decision-reason {
  font-size: 13px;
  color: var(--text);
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.08);
}
@media (max-width: 600px) {
  .decision-amounts { grid-template-columns: repeat(2, 1fr); }
}

/* Rule editor cards */
.tpl-form-wrap .rules-host {
  display: flex; flex-direction: column; gap: 10px;
}
.rule-editor-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}
.rule-editor-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.rule-editor-priority {
  display: flex; align-items: center; gap: 6px;
}
.rule-editor-priority label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}
.rule-editor-name {
  flex: 1;
  font-weight: 600;
}
.rule-del-btn { color: #ef4444; }
.rule-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.rule-when-wrap, .rule-then-wrap {
  background: rgba(0,0,0,0.02);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
}
.rule-conditions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.rule-then-grid {
  display: grid;
  grid-template-columns: 160px 100px 1fr 1fr;
  gap: 6px;
}
@media (max-width: 768px) {
  .rule-conditions-grid { grid-template-columns: repeat(2, 1fr); }
  .rule-then-grid { grid-template-columns: 1fr 1fr; }
}
.check-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
  cursor: pointer;
  padding-top: 24px;
}
.check-label input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer;
}

/* ============================================================
   Profitability Helper Classes
   ============================================================ */
.text-success { color: #10b981; }
.text-danger  { color: #ef4444; }
.text-info    { color: #3b82f6; }
.fw-700       { font-weight: 700; }

/* ============================================================
   Contract Clauses
   ============================================================ */
.clause-applicable-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 768px) {
  .clause-applicable-grid { grid-template-columns: repeat(2, 1fr); }
}
.clause-type-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
  position: relative;
}
.clause-type-chip:hover {
  border-color: var(--brand);
  background: var(--brand-tint);
}
.clause-type-chip.is-checked {
  border-color: var(--brand);
  background: var(--brand-tint);
  box-shadow: 0 0 0 1px var(--brand);
}
.clause-type-chip input[type="checkbox"] {
  position: absolute; top: 8px; right: 8px;
  width: 18px; height: 18px;
}
html[dir="rtl"] .clause-type-chip input[type="checkbox"] {
  right: auto; left: 8px;
}
.clause-type-chip .chip-code {
  font-weight: 700;
  font-size: 18px;
  color: var(--brand-darker);
  letter-spacing: 1px;
}
.clause-type-chip .chip-label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 2px;
}

/* Status badge for "onhold" clause type custom */
.status-onhold { background: #f3e8ff; color: #6b21a8; border-color: #d8b4fe; }

/* ============================================================
   Contract Clauses — inside Contract form
   ============================================================ */
.contract-clauses-host {
  display: flex; flex-direction: column; gap: 8px;
}
.contract-clause-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.contract-clause-head {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 8px;
}
.contract-clause-head .clause-order {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px;
  background: var(--brand-tint);
  color: var(--brand-darker);
  font-weight: 700; font-size: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.clause-title-input {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  min-width: 0;
}
.contract-clause-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.contract-clause-body textarea {
  font-size: 12px;
  padding: 6px 8px;
}
@media (max-width: 768px) {
  .contract-clause-body { grid-template-columns: 1fr; }
}

/* ============================================================
   Clause Number Display + Bullets Editor
   ============================================================ */
.clause-number-display {
  display: flex; align-items: center;
  background: var(--brand-tint);
  padding: 8px 14px;
  border-radius: 6px;
  margin-bottom: 12px;
}
.clause-number-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--brand);
  color: white;
  font-weight: 700; font-size: 14px;
  border-radius: 50%;
}
.bullets-host {
  display: flex; flex-direction: column; gap: 8px;
}
.bullet-row {
  display: grid;
  grid-template-columns: 32px 1fr 1fr 110px;
  gap: 8px;
  align-items: start;
  padding: 8px;
  background: rgba(0,0,0,0.02);
  border-radius: 6px;
}
.bullet-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: white;
  border: 1px solid var(--border);
  font-weight: 600; font-size: 12px;
  border-radius: 50%;
  margin-top: 4px;
}
.bullet-input {
  width: 100%;
  font-size: 12px;
  padding: 6px 8px;
  resize: vertical;
}
.bullet-actions {
  display: flex; gap: 2px; justify-content: flex-end;
}
@media (max-width: 768px) {
  .bullet-row { grid-template-columns: 1fr; }
  .bullet-actions { justify-content: flex-start; }
}

/* Sub-clause readonly display */
.sub-clause-readonly ul {
  list-style: disc;
  padding-inline-start: 20px;
}

/* ============================================================
   Users Banner in Settings → Permissions
   ============================================================ */
.users-banner-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--brand-tint, #e0f7f5) 0%, #fff 100%);
  border: 1px solid var(--brand, #1ABCB0);
  border-radius: 10px;
  margin-bottom: 20px;
}
.users-banner-icon { font-size: 36px; flex-shrink: 0; }
.users-banner-content { flex: 1; min-width: 0; }
.users-banner-title {
  font-weight: 700; font-size: 15px;
  color: var(--brand-darker, #0E8A82);
  margin-bottom: 2px;
}
.users-banner-text { font-size: 13px; color: var(--text-muted); }
.users-banner-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

@media (max-width: 768px) {
  .users-banner-card { flex-direction: column; align-items: stretch; text-align: center; }
  .users-banner-actions { justify-content: center; }
}

/* ============================================================
   Role Selector Chips
   ============================================================ */
.role-selector-wrap { margin-bottom: 8px; }
.role-selector-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px;
}
.role-selector-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 100px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
.role-selector-chip:hover {
  border-color: var(--brand);
  background: var(--brand-tint, #e0f7f5);
}
.role-selector-chip.is-selected {
  background: var(--brand);
  border-color: var(--brand);
  color: white;
  font-weight: 600;
}
.role-selector-chip .chip-name { white-space: nowrap; }
.role-selector-chip .chip-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 18px; padding: 0 5px;
  background: rgba(255,255,255,0.3);
  border-radius: 9px;
  font-size: 10px; font-weight: 700;
}
.role-selector-chip:not(.is-selected) .chip-count {
  background: var(--brand-tint, #e0f7f5);
  color: var(--brand-darker);
}

/* ============================================================
   Password Strength Meter
   ============================================================ */
.pw-meter { margin: 4px 0 12px 0; }
.pw-meter-bar {
  width: 100%; height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  overflow: hidden;
}
.pw-meter-fill {
  height: 100%; width: 0%;
  background: #ef4444;
  transition: width 0.2s, background 0.2s;
}
.pw-meter-label {
  font-size: 11px; margin-top: 4px;
  font-weight: 600;
}

/* ============================================================
   Role Description Box (in user form)
   ============================================================ */
.role-description-box {
  padding: 12px 14px;
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: -4px;
  margin-bottom: 12px;
}
.role-description-box:empty { display: none; }
.role-desc-header { font-size: 14px; margin-bottom: 4px; }
.role-desc-text { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; line-height: 1.5; }
.role-desc-meta { font-size: 11px; color: var(--brand-darker, #0E8A82); font-weight: 600; }

/* ============================================================
   Integrations Hub
   ============================================================ */
.integration-warning {
  display: flex;
  gap: 14px;
  padding: 14px 18px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  margin-bottom: 20px;
}
.integration-warning .warning-icon { font-size: 28px; flex-shrink: 0; }
.integration-warning .warning-title {
  font-weight: 700; font-size: 14px; color: #92400e;
  margin-bottom: 4px;
}
.integration-warning .warning-text {
  font-size: 13px; color: #78350f; line-height: 1.5;
}

.integration-section {
  margin-top: 28px;
  margin-bottom: 24px;
}
.integration-section-header {
  display: flex; gap: 12px; align-items: center;
  padding: 12px 0;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--border, #e5e7eb);
}
.integration-cat-icon { font-size: 28px; }
.integration-cat-title {
  font-weight: 700; font-size: 16px;
  color: var(--brand-darker, #0E8A82);
}
.integration-cat-desc {
  font-size: 12px; color: var(--text-muted);
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.integration-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.15s;
}
.integration-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: var(--brand);
}
.integration-card.is-enabled {
  border-color: #10b981;
  background: linear-gradient(135deg, #f0fdf4 0%, #fff 100%);
}

.integration-card-header {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.integration-card-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-tint, #e0f7f5);
  border-radius: 10px;
  font-size: 22px;
  flex-shrink: 0;
}
.integration-card-meta { flex: 1; min-width: 0; }
.integration-card-name {
  font-weight: 700; font-size: 14px;
  margin-bottom: 4px;
}
.integration-card-status .status-badge {
  display: inline-block;
  padding: 2px 8px; border-radius: 100px;
  font-size: 11px; font-weight: 600;
  background: #f3f4f6; color: #6b7280;
}
.integration-card-status .status-completed {
  background: #d1fae5; color: #065f46;
}

.integration-card-body {
  padding: 12px 16px;
  flex: 1;
}
.integration-card-desc {
  font-size: 12px; color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 6px;
}
.integration-card-meta-text {
  font-size: 11px;
  color: var(--text-muted);
}

.integration-card-footer {
  padding: 10px 16px;
  display: flex; gap: 8px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.01);
}

/* Provider config modal */
.provider-info-banner {
  display: flex; gap: 14px;
  padding: 14px;
  background: var(--brand-tint, #e0f7f5);
  border-radius: 8px;
  margin-bottom: 16px;
}
.provider-info-icon {
  font-size: 32px; flex-shrink: 0;
}
.provider-info-name {
  font-weight: 700; font-size: 16px; margin-bottom: 4px;
  color: var(--brand-darker);
}
.provider-info-desc {
  font-size: 13px; color: var(--text-muted); margin-bottom: 6px;
}

.form-help {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.integration-test-result {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
}
.integration-test-result.is-testing {
  background: #fef3c7; color: #92400e;
  border: 1px solid #fde68a;
}
.integration-test-result.is-success {
  background: #d1fae5; color: #065f46;
  border: 1px solid #a7f3d0;
}
.integration-test-result.is-error {
  background: #fee2e2; color: #991b1b;
  border: 1px solid #fca5a5;
}

/* ============================================================
   GPS Tracking Page
   ============================================================ */
.gps-provider-badge {
  padding: 6px 12px;
  border-radius: 100px;
  font-size: 12px; font-weight: 600;
}
.gps-provider-badge.is-live {
  background: #d1fae5; color: #065f46;
}
.gps-provider-badge.is-mock {
  background: #fef3c7; color: #92400e;
}

.gps-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  height: calc(100vh - 280px);
  min-height: 500px;
  margin-top: 16px;
}

@media (max-width: 1024px) {
  .gps-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.gps-sidebar {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.gps-sidebar-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.01);
}
.gps-sidebar-header h3 {
  margin: 0 0 8px 0;
  font-size: 14px; font-weight: 700;
}
.gps-search-wrap input {
  width: 100%;
  font-size: 12px;
  padding: 6px 10px;
}
.gps-vehicles-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.gps-vehicle-card {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
}
.gps-vehicle-card:hover {
  border-color: var(--brand);
  background: var(--brand-tint, #e0f7f5);
}
.gps-vehicle-card.is-selected {
  border-color: var(--brand);
  background: var(--brand-tint);
  box-shadow: 0 0 0 1px var(--brand);
}
.gps-vehicle-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.gps-status-dot {
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: white; font-size: 10px;
  flex-shrink: 0;
}
.gps-vehicle-plate {
  font-family: 'Courier New', monospace;
  font-weight: 700; font-size: 13px;
  flex: 1;
}
.gps-vehicle-status {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase;
}
.gps-vehicle-name {
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 2px;
}
.gps-vehicle-driver {
  font-size: 11px; color: var(--text-muted);
  margin-bottom: 4px;
}
.gps-vehicle-stats {
  display: flex; gap: 8px;
  font-size: 11px;
  flex-wrap: wrap;
}
.gps-vehicle-stats span { white-space: nowrap; }
.gps-vehicle-location {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.gps-map-wrap {
  position: relative;
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.gps-map {
  width: 100%;
  height: 100%;
  min-height: 500px;
  z-index: 1;
}

/* Custom GPS markers */
.gps-marker-icon { background: transparent !important; border: none !important; }
.gps-marker {
  display: flex; flex-direction: column; align-items: center;
  padding: 3px 6px;
  border-radius: 6px;
  color: white;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
  border: 2px solid white;
}
.gps-marker-arrow {
  font-size: 10px;
  line-height: 1;
}
.gps-marker-plate {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  letter-spacing: 0.5px;
}

/* GPS popup */
.gps-popup-header {
  display: flex; justify-content: space-between;
  border-bottom: 2px solid;
  padding-bottom: 4px;
  margin-bottom: 6px;
  font-size: 13px;
}
.gps-popup-body {
  font-size: 12px;
  line-height: 1.7;
}
.gps-popup-body div {
  margin-bottom: 2px;
}

/* GPS detail panel */
.gps-detail-panel {
  position: absolute;
  bottom: 14px;
  left: 14px;
  right: 14px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 500;
  max-height: 50%;
  overflow-y: auto;
}
html[dir="rtl"] .gps-detail-panel {
  left: 14px; right: 14px;
}
.gps-detail-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
.gps-detail-body {
  padding: 14px;
}
.gps-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
@media (max-width: 768px) {
  .gps-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
.gps-stat {
  text-align: center;
  padding: 8px;
  background: rgba(0,0,0,0.03);
  border-radius: 6px;
}
.gps-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.gps-stat-value {
  font-weight: 700;
  font-size: 16px;
  color: var(--brand-darker);
}
.gps-stat-value small {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}
.gps-detail-row {
  font-size: 13px;
  padding: 4px 0;
}
.gps-detail-actions {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
