@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #185FA5;
  --primary-dark: #124a82;
  --primary-light: #e8f0fb;
  --bg: #f4f6fa;
  --white: #fff;
  --border: #dde3ec;
  --text: #2c3e50;
  --text-muted: #6c757d;
  --sidebar-w: 240px;
  --header-h: 64px;
  --red: #dc3545;
  --orange: #fd7e14;
  --yellow: #ffc107;
  --green: #28a745;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
}

html { direction: rtl; font-family: Tajawal, sans-serif; font-size: 15px; }
body { background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── Layout ─────────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 200;
  overflow-y: auto;
  transition: transform .3s ease;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.15);
  text-align: center;
  position: relative;
}
.sidebar-logo h2 { color: #fff; font-size: 1.2rem; font-weight: 700; }
.sidebar-logo p  { color: rgba(255,255,255,.7); font-size: .78rem; margin-top: 4px; }

.sidebar-user-info {
  display: none;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.12);
  text-align: center;
  gap: 8px;
  flex-direction: column;
  align-items: center;
}
.sidebar-user-name {
  color: #fff;
  font-size: .95rem;
  font-weight: 600;
  line-height: 1.3;
}
.sidebar-user-dept {
  font-size: .78rem;
  color: rgba(255,255,255,.7);
  margin-top: 2px;
}
.sidebar-role-badge {
  background: rgba(255,255,255,.18);
  color: #fff;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-link {
  display: block;
  padding: 11px 20px;
  color: rgba(255,255,255,.82);
  text-decoration: none;
  font-size: .92rem;
  transition: background .18s, color .18s;
  border-right: 3px solid transparent;
}
.nav-link:hover, .nav-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-right-color: #fff;
}

.main-wrapper {
  margin-right: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  flex: 1;
}

/* ── Header ─────────────────────────────────────────────── */
.main-header {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 50;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.header-logo  { height: 60px; width: auto; object-fit: contain; flex-shrink: 0; }
.header-brand h1 { font-size: 1.05rem; font-weight: 700; color: var(--primary); }
.header-brand p  { font-size: .78rem; color: var(--text-muted); }
.header-start { display: flex; align-items: center; gap: 10px; min-width: 0; }
.header-user { display: flex; align-items: center; gap: 12px; }
.user-info   { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.user-name   { font-weight: 600; font-size: .9rem; }
.user-dept   { font-size: .73rem; color: var(--text-muted); }
.role-badge  {
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .78rem;
  font-weight: 600;
}
.change-password-btn {
  background: none;
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: .85rem;
  text-decoration: none;
  transition: .2s;
}
.change-password-btn:hover { background: var(--primary); color: #fff; }
.logout-btn {
  background: none;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 5px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: .85rem;
  text-decoration: none;
  transition: .2s;
}
.logout-btn:hover { background: var(--red); color: #fff; }

/* ── Page Content ───────────────────────────────────────── */
.page-content { padding: 28px; flex: 1; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--primary); margin-bottom: 20px; }

/* ── Cards ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
  border-top: 4px solid var(--primary);
}
.stat-card.danger  { border-top-color: var(--red); }
.stat-card.warning { border-top-color: var(--orange); }
.stat-card.success { border-top-color: var(--green); }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-card.danger  .stat-value { color: var(--red); }
.stat-card.warning .stat-value { color: var(--orange); }
.stat-card.success .stat-value { color: var(--green); }
.stat-label { font-size: .85rem; color: var(--text-muted); margin-top: 6px; }

/* ── Charts ─────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.chart-card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.chart-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 14px; color: var(--text); }
.chart-canvas-wrap { position: relative; height: 220px; }

/* ── Tables ─────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.card-header h2 { font-size: 1rem; font-weight: 600; color: var(--text); }
.card-body { padding: 0; }

table { width: 100%; border-collapse: collapse; }
thead tr { background: #f8f9fb; }
th {
  padding: 11px 14px;
  text-align: right;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  font-size: .88rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fb; }
.empty-row { text-align: center; color: var(--text-muted); padding: 30px !important; }
.row-overdue td { background: #fff5f5; }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-submitted   { background: #e8f4fd; color: #0d6efd; }
.badge-review      { background: #fff3cd; color: #856404; }
.badge-action      { background: #ffe8cc; color: #c45a00; }
.badge-pending     { background: #f0e8ff; color: #6f42c1; }
.badge-closed      { background: #d4edda; color: #155724; }
.badge-rejected    { background: #f8d7da; color: #721c24; }
.badge-critical    { background: #f8d7da; color: #721c24; }
.badge-serious     { background: #ffe8cc; color: #c45a00; }
.badge-moderate    { background: #fff3cd; color: #856404; }
.badge-minor       { background: #d4edda; color: #155724; }
.badge-classif-pending  { background: #e9ecef; color: #495057; }
.badge-classif-incident { background: #e8f4fd; color: #0d6efd; }
.badge-classif-nearmiss { background: #ffe8cc; color: #c45a00; }
.badge-classif-adverse  { background: #f8d7da; color: #721c24; }
.badge-classif-sentinel { background: #ede8ff; color: #4b0082; }
.badge-dept-response    { background: #cce5ff; color: #004085; }

/* ── Department Response Workflow ─────────────────────────── */
.dept-response-alert {
  background: #fff8e1;
  border: 2px solid #ffc107;
  border-radius: 8px;
  padding: 18px 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.dept-request-box {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-right: 4px solid #fd7e14;
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: .95rem;
}
.comment-dept-response {
  background: #e8f4ff;
  border-right: 4px solid #0d6efd;
  border-radius: 6px;
}
.dept-response-label-tag {
  display: inline-block;
  background: #0d6efd;
  color: #fff;
  font-size: .72rem;
  padding: 2px 10px;
  border-radius: 12px;
  margin-bottom: 6px;
  font-weight: 600;
}
.comment-management-directive {
  background: #fffbeb;
  border-right: 4px solid #d4a017;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(212,160,23,.15);
}
.management-directive-label-tag {
  display: inline-block;
  background: #d4a017;
  color: #fff;
  font-size: .72rem;
  padding: 2px 10px;
  border-radius: 12px;
  margin-bottom: 6px;
  font-weight: 700;
  letter-spacing: .02em;
}
.management-directive-form {
  background: #fffbeb;
  border: 1px solid #d4a017;
  border-radius: 8px;
  padding: 16px;
  margin-top: 20px;
}
.management-directive-form-title {
  font-weight: 700;
  color: #b8860b;
  font-size: .95rem;
  margin-bottom: 12px;
}
.btn-management-directive {
  background: #d4a017;
  border: 1px solid #c89600;
  color: #fff;
  font-weight: 600;
}
.btn-management-directive:hover {
  background: #b8860b;
  border-color: #a07500;
  color: #fff;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .88rem;
  font-weight: 500;
  text-decoration: none;
  transition: .18s;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #1e7e34; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b02a37; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }

/* ── Forms ──────────────────────────────────────────────── */
.form-card {
  background: var(--white);
  border-radius: 12px;
  padding: 28px;
  box-shadow: var(--shadow);
  max-width: 860px;
}
.form-section { margin-bottom: 28px; }
.form-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .85rem; font-weight: 600; color: var(--text); }
.form-group .required::after { content: ' *'; color: var(--red); }
.form-control {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: inherit;
  font-size: .9rem;
  color: var(--text);
  background: #fff;
  transition: border-color .2s;
  direction: rtl;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(24,95,165,.12); }
textarea.form-control { resize: vertical; min-height: 100px; }
.form-control.error { border-color: var(--red); }
.field-error { color: var(--red); font-size: .78rem; margin-top: 2px; }

/* severity radio */
.sev-options { display: flex; gap: 10px; flex-wrap: wrap; }
.sev-radio { display: none; }
.sev-label {
  padding: 7px 16px;
  border-radius: 20px;
  border: 2px solid var(--border);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  transition: .2s;
}
.sev-radio[value="حرج"]:checked   + .sev-label { background: #f8d7da; border-color: #dc3545; color: #721c24; }
.sev-radio[value="خطير"]:checked  + .sev-label { background: #ffe8cc; border-color: #fd7e14; color: #c45a00; }
.sev-radio[value="متوسط"]:checked + .sev-label { background: #fff3cd; border-color: #ffc107; color: #856404; }
.sev-radio[value="بسيط"]:checked  + .sev-label { background: #d4edda; border-color: #28a745; color: #155724; }

/* toggle */
.toggle-wrap { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-input { width: 40px; height: 22px; appearance: none; background: var(--border); border-radius: 11px; position: relative; cursor: pointer; transition: .2s; }
.toggle-input:checked { background: var(--primary); }
.toggle-input::after { content:''; position:absolute; width:18px; height:18px; background:#fff; border-radius:50%; top:2px; right:2px; transition:.2s; }
.toggle-input:checked::after { right:auto; left:2px; }
.toggle-label { font-size: .88rem; }

.form-actions { display: flex; gap: 12px; margin-top: 24px; }

/* ── Filters ─────────────────────────────────────────────── */
.filter-bar {
  background: var(--white);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.filter-bar select, .filter-bar input[type="text"], .filter-bar input[type="date"] {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: .85rem;
  direction: rtl;
  background: #fff;
}
.filter-bar select:focus, .filter-bar input:focus { outline: none; border-color: var(--primary); }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: .9rem;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-danger  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* ── Ref Link ────────────────────────────────────────────── */
.ref-link { color: var(--primary); font-weight: 600; text-decoration: none; }
.ref-link:hover { text-decoration: underline; }

/* ── OVR Detail ──────────────────────────────────────────── */
.detail-header {
  background: var(--white);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.detail-ref { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.detail-badges { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: .9rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: .2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.detail-field { background: var(--white); border-radius: 8px; padding: 14px 16px; box-shadow: var(--shadow); }
.detail-field.full { grid-column: 1 / -1; }
.detail-field label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; display: block; margin-bottom: 4px; }
.detail-field .field-val { font-size: .92rem; color: var(--text); line-height: 1.5; }

/* Timeline */
.timeline { padding: 8px 0; }
.timeline-item { display: flex; gap: 14px; margin-bottom: 20px; }
.timeline-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); flex-shrink: 0; margin-top: 4px; }
.timeline-body { flex: 1; }
.timeline-change { color: var(--text-muted); font-size: .85rem; margin-right: 8px; }
.timeline-meta { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }

/* Actions list */
.action-item {
  background: var(--white);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border-right: 4px solid var(--primary);
}
.action-item.action-overdue { border-right-color: var(--red); }
.action-header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.action-desc { font-weight: 500; flex: 1; }
.action-meta { font-size: .82rem; color: var(--text-muted); }

/* Comments */
.comment-item {
  background: var(--white);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.comment-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.role-tag { background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 10px; font-size: .72rem; }
.comment-date { font-size: .78rem; color: var(--text-muted); margin-right: auto; }
.comment-item p { font-size: .9rem; line-height: 1.6; }

/* inline form */
.inline-form { background: var(--bg); border-radius: 8px; padding: 14px; margin-top: 16px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.flex-grow { flex: 1; min-width: 200px; }
.align-end { justify-content: flex-end; }

/* ── My OVRs ─────────────────────────────────────────────── */
.ovr-cards-grid { display: grid; gap: 16px; }
.ovr-card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.ovr-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.ovr-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.card-meta { font-size: .82rem; color: var(--text-muted); margin-bottom: 14px; }
.card-actions { margin-top: 12px; }

/* Status tracker */
.status-tracker { display: flex; align-items: flex-start; gap: 0; overflow-x: auto; padding: 4px 0; }
.step-item { display: flex; flex-direction: column; align-items: center; min-width: 90px; position: relative; }
.step-item:not(:last-child)::before {
  content: '';
  position: absolute;
  top: 8px;
  left: -50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.step-item.step-done:not(:last-child)::before { background: var(--green); }
.step-dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border); background: #fff; z-index: 1; margin-bottom: 6px; }
.step-done   .step-dot { background: var(--green); border-color: var(--green); }
.step-active .step-dot { background: var(--primary); border-color: var(--primary); }
.step-label { font-size: .72rem; text-align: center; color: var(--text-muted); line-height: 1.2; max-width: 80px; }
.step-done   .step-label { color: var(--green); }
.step-active .step-label { color: var(--primary); font-weight: 600; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; justify-content: center; padding: 20px; flex-wrap: wrap; }
.page-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
  font-size: .85rem;
  transition: .18s;
}
.page-btn:hover { background: var(--primary-light); border-color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,.45);
  justify-content: center;
  align-items: center;
}
.modal {
  background: var(--white);
  border-radius: 14px;
  padding: 28px;
  max-width: 560px;
  width: 94%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 18px; color: var(--primary); }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ── Login ───────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #185FA5 0%, #0d3d6b 100%);
  direction: rtl;
}
.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 1.3rem; font-weight: 700; color: var(--primary); }
.login-logo p  { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }
.login-title { font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 20px; }

/* ── Misc ────────────────────────────────────────────────── */
.text-danger  { color: var(--red); }
.text-warning { color: var(--orange); }
.empty-msg { color: var(--text-muted); padding: 20px; text-align: center; }
.section-sep { height: 1px; background: var(--border); margin: 20px 0; }
code { background: #f1f3f5; padding: 2px 6px; border-radius: 4px; font-family: monospace; font-size: .82rem; }
.info-row { display: flex; gap: 8px; margin-bottom: 6px; font-size: .9rem; }
.info-label { font-weight: 600; min-width: 140px; color: var(--text-muted); }

/* ── Reports ─────────────────────────────────────────────── */
.report-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }

/* ── Sidebar Backdrop ────────────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 150;
}
.sidebar-backdrop.active { display: block; }

/* ── Hamburger Button ────────────────────────────────────── */
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  border-radius: 8px;
  flex-shrink: 0;
  padding: 0;
  transition: background .2s;
}
.hamburger-btn:hover { background: var(--bg); }
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .3s, opacity .3s;
}
.hamburger-btn.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Sidebar Close Button ────────────────────────────────── */
.sidebar-close {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 30px;
  text-align: center;
  padding: 0;
  transition: background .2s;
}
.sidebar-close:hover { background: rgba(255,255,255,.3); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .form-grid-2, .form-grid-3, .detail-grid { grid-template-columns: 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
  .main-header { padding: 0 14px; }
  .page-content { padding: 18px; }
  .report-stats-grid { grid-template-columns: 1fr; }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .filter-bar select,
  .filter-bar input[type="text"],
  .filter-bar input[type="date"] { width: 100%; min-height: 40px; }
  .filter-bar .btn { width: 100%; justify-content: center; min-height: 40px; }

  .btn { min-height: 40px; }
  .form-control { min-height: 40px; }
}

@media (max-width: 576px) {
  /* ── Sidebar overlay ────────────────────────────── */
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .sidebar-user-info { display: flex; }
  .nav-link { padding: 14px 20px; font-size: .95rem; }

  /* ── Main layout ────────────────────────────────── */
  .main-wrapper { margin-right: 0; }
  .page-content { padding: 12px; }
  .page-title { font-size: 1.2rem; }

  /* ── Header ─────────────────────────────────────── */
  .hamburger-btn { display: inline-flex; }
  .main-header {
    height: auto;
    min-height: var(--header-h);
    padding: 8px 12px;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .header-brand h1 { font-size: .88rem; }
  .header-brand p  { display: none; }
  .user-name  { display: none; }
  .role-badge { display: none; }
  .change-password-btn { padding: 7px 12px; font-size: .8rem; }
  .logout-btn { padding: 7px 12px; font-size: .8rem; }

  /* ── Touch-friendly sizes (min 44px) ────────────── */
  .btn          { min-height: 44px; padding: 10px 16px; }
  .btn-sm       { min-height: 40px; padding: 8px 14px; font-size: .82rem; }
  .form-control { min-height: 44px; padding: 10px 12px; font-size: .95rem; }
  .filter-bar select,
  .filter-bar input[type="text"],
  .filter-bar input[type="date"] { min-height: 44px; padding: 10px 12px; font-size: .95rem; }
  .tab-btn   { min-height: 46px; padding: 12px 16px; }
  .page-btn  { min-height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; }
  .sev-label { min-height: 44px; padding: 10px 18px; display: inline-flex; align-items: center; }

  /* ── Tabs horizontal scroll ─────────────────────── */
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; }

  /* ── Cards ──────────────────────────────────────── */
  .card { overflow: visible; border-radius: 10px; }
  .card > .card-body { overflow: visible !important; padding: 0; }
  .stat-card { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-value { font-size: 1.6rem; }

  /* ── Responsive Tables → Cards ──────────────────── */
  .responsive-table thead { display: none; }

  .responsive-table tbody tr {
    display: block;
    background: var(--white);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin: 12px;
    padding: 4px 0;
    border: 1px solid var(--border);
  }
  .responsive-table tbody tr:last-child { margin-bottom: 12px; }

  .responsive-table tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #f0f2f5;
    border-right: none;
    font-size: .87rem;
    text-align: right;
  }
  .responsive-table tbody tr td:last-child { border-bottom: none; }

  .responsive-table tbody td::before {
    content: attr(data-label);
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    min-width: 80px;
    flex-shrink: 0;
    text-align: right;
  }
  .responsive-table tbody tr:hover td { background: transparent; }

  .responsive-table td.empty-row {
    display: flex;
    justify-content: center;
    border-bottom: none;
    padding: 24px 14px !important;
  }
  .responsive-table td.empty-row::before { display: none; }

  .responsive-table tr.row-overdue { background: #fff5f5; border-color: #f5c6cb; }
  .responsive-table tr.row-overdue td { background: transparent; }

  /* ── Detail header ──────────────────────────────── */
  .detail-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .detail-actions { flex-wrap: wrap; gap: 6px; }
  .detail-ref { font-size: 1.1rem; }

  /* ── Form actions ───────────────────────────────── */
  .form-actions { flex-wrap: wrap; gap: 10px; }
  .form-actions .btn { flex: 1 1 auto; justify-content: center; min-width: 120px; }

  /* ── Login ──────────────────────────────────────── */
  .login-card { padding: 28px 20px; margin: 12px; }

  /* ── Modals ─────────────────────────────────────── */
  .modal { padding: 20px 16px; width: 96%; }

  /* ── Info rows ──────────────────────────────────── */
  .info-row { flex-direction: column; gap: 2px; }
  .info-label { min-width: unset; }

  /* ── OVR cards grid ─────────────────────────────── */
  .ovr-cards-grid { gap: 12px; }

  /* ── Pagination ─────────────────────────────────── */
  .pagination { gap: 4px; padding: 14px 8px; }
}

/* ── File Attachments ─────────────────────────────────── */
.form-control-file {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--white);
  font-family: inherit;
  font-size: .88rem;
  color: var(--text);
  cursor: pointer;
}
.form-control-file:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.form-hint { display: block; margin-top: 5px; font-size: .78rem; color: var(--text-muted); }

.attachments-section { margin-top: 20px; }
.attachments-label {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.attachments-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.attachment-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  width: 110px;
  transition: box-shadow .18s, border-color .18s;
  overflow: hidden;
}
.attachment-item:hover { box-shadow: var(--shadow); border-color: var(--primary); }
.attachment-thumb {
  width: 88px;
  height: 72px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
}
.attachment-pdf-icon {
  width: 88px;
  height: 72px;
  background: #fee2e2;
  color: #dc2626;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .05em;
}
.attachment-name {
  font-size: .72rem;
  color: var(--text-muted);
  text-align: center;
  word-break: break-all;
  line-height: 1.3;
  max-width: 90px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* ── File Queue Widget ────────────────────────────────────── */
.file-queue-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.file-queue-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .85rem;
}
.file-queue-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-queue-size { color: var(--text-muted); font-size: .78rem; white-space: nowrap; flex-shrink: 0; }
.file-queue-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--red);
  font-size: 1rem;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1;
}
.file-queue-remove:hover { color: #b02a37; }

/* ── PWA Install Banner ───────────────────────────────────── */
.pwa-banner {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: var(--primary);
  color: #fff;
  padding: 12px 16px;
  align-items: center;
  gap: 10px;
  font-family: Tajawal, sans-serif;
  font-size: .88rem;
  direction: rtl;
  box-shadow: 0 -2px 12px rgba(0,0,0,.18);
}
.pwa-banner.show { display: flex; }
.pwa-banner-text { flex: 1; line-height: 1.4; }
.pwa-install-btn {
  background: #fff;
  color: var(--primary);
  border: none;
  border-radius: 6px;
  padding: 7px 18px;
  font-family: Tajawal, sans-serif;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.pwa-install-btn:hover { background: #e8f0fb; }
.pwa-dismiss-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.75);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 6px;
  line-height: 1;
  flex-shrink: 0;
}
.pwa-dismiss-btn:hover { color: #fff; }

/* ── KPI Dashboard ───────────────────────────────────────── */
.kpi-period-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.kpi-period-tab {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 500;
  text-decoration: none;
  transition: background .16s, color .16s, border-color .16s;
  white-space: nowrap;
}
.kpi-period-tab:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.kpi-period-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); font-weight: 600; }

.kpi-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.kpi-card { position: relative; }
.kpi-card-icon {
  font-size: 1.4rem;
  margin-bottom: 8px;
  display: block;
  opacity: .75;
}
.kpi-card-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 6px;
}

/* ── Notification Bell (header) ──────────────────────────── */
.notif-bell-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  transition: background .18s, color .18s;
  flex-shrink: 0;
}
.notif-bell-btn:hover { background: var(--primary-light); color: var(--primary); }
.notif-bell-icon { width: 20px; height: 20px; display: block; }
.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: Arial, sans-serif;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  pointer-events: none;
}

/* ── Sidebar notification badge ──────────────────────────── */
.sidebar-notif-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  font-family: Arial, sans-serif;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 4px;
  margin-right: 6px;
  vertical-align: middle;
}

/* ── Notifications page list ─────────────────────────────── */
.notif-list { display: flex; flex-direction: column; }
.notif-item { border-bottom: 1px solid var(--border); }
.notif-item:last-child { border-bottom: none; }
.notif-item-unread { background: #edf3fc; }

.notif-item-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 20px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: right;
  font-family: Tajawal, sans-serif;
  transition: background .15s;
}
.notif-item-btn:hover { background: rgba(24,95,165,.07); }

.notif-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}
.notif-dot-read { background: var(--border); }

.notif-item-body { flex: 1; text-align: right; }
.notif-item-msg  { font-size: .93rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.notif-item-unread .notif-item-msg { color: var(--primary-dark); }
.notif-item-time { font-size: .78rem; color: var(--text-muted); }
.notif-arrow     { color: var(--text-muted); font-size: 1rem; flex-shrink: 0; }

/* ── Unread count badge on page title ────────────────────── */
.notif-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--red);
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  font-family: Arial, sans-serif;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  padding: 0 6px;
  margin-right: 8px;
  vertical-align: middle;
}

/* ── Sentinel Events ─────────────────────────────────────── */
.badge-sentinel { background:#f8d7da; color:#721c24; border:1px solid #f5c6cb; font-weight:700; }

.sentinel-countdowns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px,1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.sentinel-countdown {
  border: 2px solid #dee2e6;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.countdown-num   { font-size: 1.55rem; font-weight: 700; margin-bottom: 6px; }
.countdown-label { font-size: .88rem; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.countdown-date  { font-size: .76rem; color: var(--text-muted); }

.sentinel-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px 26px;
  margin-bottom: 20px;
}

.sentinel-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
}

tr.sentinel-row-overdue { background: #fff5f5; }
tr.sentinel-row-warning { background: #fffbf0; }
tr.sentinel-row-closed  { background: #f8f9fa; opacity: .82; }
