/* ==========================================================================
   DataTech Lawyer — Design System
   Natural office look: slate + muted teal, flat surfaces, cool gray ground
   ========================================================================== */

:root {
  --navy: #2f3f4f;
  --navy-light: #425466;
  --navy-dark: #243240;
  --gold: #3f7a6b;
  --gold-light: #5b9586;
  --gold-dark: #2f5e52;
  --off-white: #eef1f4;
  --ink: #243039;
  --muted: #66707a;
  --border: #d5dbe2;
  --white: #ffffff;

  --success: #2d7a55;
  --success-bg: #e8f5ee;
  --danger: #b34a3f;
  --danger-bg: #f8ebe9;
  --warning: #9a6b2f;
  --warning-bg: #f7f0e4;
  --info: #3a6d8c;
  --info-bg: #e8f1f6;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(36, 48, 64, 0.06);
  --shadow-md: 0 4px 12px rgba(36, 48, 64, 0.08);
  --shadow-lg: 0 8px 20px rgba(36, 48, 64, 0.1);
  --transition: 160ms ease;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Tajawal', 'Segoe UI', Tahoma, sans-serif;
  color: var(--ink);
  background-color: var(--off-white);
  background-image: none;
  line-height: 1.6;
  direction: rtl;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

::selection {
  background: rgba(63, 122, 107, 0.25);
  color: var(--ink);
}

/* ---------------------------------- Layout ---------------------------------- */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--navy);
  color: #f4f6f8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: none;
  font-weight: 800;
  font-size: 13px;
}

.brand-mark svg {
  width: 24px;
  height: 24px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.home-nav-btn {
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #f4f6f8;
  border: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  transition: background var(--transition);
}

.home-nav-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  transform: none;
}

.home-nav-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  color: #f4f6f8;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: background var(--transition);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: none;
}

.icon-btn svg {
  width: 19px;
  height: 19px;
}

.icon-btn .badge-dot {
  position: absolute;
  top: -2px;
  left: -2px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--navy);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gold);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
}

.user-role {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.7);
}

.logout-form {
  display: inline-flex;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: transparent;
  color: var(--off-white);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

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

.staff-avatar,
.staff-avatar-preview {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  background: var(--off-white);
}

.staff-avatar-preview {
  display: block;
  width: 72px;
  height: 72px;
  margin-top: 10px;
}

.permission-panel {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.permission-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--off-white);
}

.permission-card > strong {
  display: block;
  margin-bottom: 10px;
  color: var(--navy);
}

.permission-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.permission-actions label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  cursor: pointer;
}

.permission-actions input {
  width: auto;
  min-height: auto;
}

.main-content {
  flex: 1;
  max-width: 1240px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

/* --------------------------------- Alerts --------------------------------- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 14px;
  border: 1px solid transparent;
  animation: slideDown 320ms ease;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(31, 138, 86, 0.25);
}

.alert-error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(179, 57, 44, 0.25);
}

.alert svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert ul {
  margin: 4px 0 0;
  padding-right: 18px;
}

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

/* ------------------------------ Page header ------------------------------ */

.page-header-area {
  margin-bottom: 22px;
}

.page-header-area:empty {
  display: none;
  margin: 0;
  padding: 0;
}

.back-row {
  margin-bottom: 14px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--navy);
  font-size: 13px;
  font-weight: 600;
  box-shadow: none;
  transition: background var(--transition), border-color var(--transition);
}

.btn-back:hover {
  transform: none;
  background: #f3f5f7;
  color: var(--navy);
  box-shadow: none;
  border-color: #c5ccd4;
}

.btn-back svg {
  width: 16px;
  height: 16px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-titles h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
}

.page-header-titles p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.page-header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------------------------- Cards ---------------------------------- */

.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card-pad {
  padding: 22px;
}

.card-hover:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}

.fade-in {
  animation: fadeIn 480ms ease both;
}

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

.stagger > * {
  opacity: 0;
  animation: fadeIn 480ms ease both;
}

.stagger > *:nth-child(1) { animation-delay: 0.02s; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.1s; }
.stagger > *:nth-child(4) { animation-delay: 0.14s; }
.stagger > *:nth-child(5) { animation-delay: 0.18s; }
.stagger > *:nth-child(6) { animation-delay: 0.22s; }
.stagger > *:nth-child(7) { animation-delay: 0.26s; }
.stagger > *:nth-child(8) { animation-delay: 0.3s; }
.stagger > *:nth-child(9) { animation-delay: 0.34s; }
.stagger > *:nth-child(10) { animation-delay: 0.38s; }
.stagger > *:nth-child(11) { animation-delay: 0.42s; }
.stagger > *:nth-child(12) { animation-delay: 0.46s; }

/* Dashboard hero */

.hero-card {
  background: var(--navy);
  border-radius: var(--radius);
  padding: 22px 24px;
  color: #f4f6f8;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.hero-card::before {
  display: none;
}

.hero-card-content {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.hero-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 8px;
}

.hero-sub {
  color: rgba(247, 245, 242, 0.75);
  margin: 0;
  font-size: 14px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

/* Stats row */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--white);
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 16px 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.stat-card:hover {
  transform: none;
  box-shadow: var(--shadow-md);
  border-color: #b7c2cc;
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e8eef2;
  color: var(--navy);
  flex-shrink: 0;
}

.stat-icon svg {
  width: 22px;
  height: 22px;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
  line-height: 1.3;
}

/* Module grid (card-based navigation) */

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 22px 0 14px;
  gap: 10px;
}

.section-title h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title h2::before {
  content: '';
  width: 4px;
  height: 18px;
  background: var(--gold);
  border-radius: 2px;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.module-grid-sm {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.module-grid-sm .module-card {
  padding: 16px;
}

.module-grid-sm .module-card p {
  display: block;
}

.module-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  position: relative;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  min-height: 168px;
}

.module-card::after {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--gold);
  opacity: 0;
  transition: opacity var(--transition);
}

.module-card:hover {
  transform: none;
  box-shadow: var(--shadow-md);
  border-color: #b7c2cc;
}

.module-card:hover::after {
  opacity: 1;
}

.module-icon {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  color: #fff;
  flex-shrink: 0;
}

.module-icon svg {
  width: 22px;
  height: 22px;
}

.module-card h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  color: var(--navy);
}

.module-card p {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
  flex: 1;
}

.module-count {
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: 6px;
  background: #f0f3f6;
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  margin-top: auto;
}

/* --------------------------------- Buttons --------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), color var(--transition), border-color var(--transition);
}

.btn svg {
  width: 17px;
  height: 17px;
}

.btn-primary {
  background: var(--navy);
  color: var(--white);
  box-shadow: none;
}

.btn-primary:hover {
  background: var(--navy-light);
}

.btn-gold {
  background: var(--gold);
  color: #fff;
  box-shadow: none;
}

.btn-gold:hover {
  background: var(--gold-dark);
  box-shadow: none;
}

.btn-outline {
  background: var(--white);
  color: var(--navy);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: var(--navy);
  transform: translateY(-2px);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(179, 57, 44, 0.25);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  transform: translateY(-2px);
}

.btn-sm {
  padding: 7px 14px;
  font-size: 12.5px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

/* --------------------------------- Forms --------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.form-group.full {
  grid-column: 1 / -1;
}

label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--navy);
}

label .req {
  color: var(--danger);
  margin-right: 3px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--white);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  transition: border-color var(--transition), box-shadow var(--transition);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(63, 122, 107, 0.18);
}

select {
  cursor: pointer;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--ink);
}

.form-check input {
  width: auto;
  accent-color: var(--navy);
}

.form-hint {
  font-size: 12px;
  color: var(--muted);
}

.form-error {
  font-size: 12.5px;
  color: var(--danger);
  font-weight: 600;
}

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-start;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* --------------------------------- Tables --------------------------------- */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

table.data-table thead th {
  background: var(--navy);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 12px 14px;
  text-align: right;
  white-space: nowrap;
}

table.data-table thead th:first-child {
  border-radius: var(--radius) 0 0 0;
}

table.data-table thead th:last-child {
  border-radius: 0 var(--radius) 0 0;
}

table.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  color: var(--ink);
}

table.data-table tbody tr {
  transition: background var(--transition);
}

table.data-table tbody tr:hover {
  background: rgba(63, 122, 107, 0.06);
}

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

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* --------------------------------- Badges --------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-gold { background: rgba(63, 122, 107, 0.14); color: #2f5e52; }
.badge-navy { background: rgba(11, 31, 58, 0.08); color: var(--navy); }
.badge-muted { background: #eef0f2; color: var(--muted); }

/* --------------------------------- Filters --------------------------------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.filter-bar .form-group {
  margin-bottom: 0;
  min-width: 160px;
}

/* --------------------------------- Empty state --------------------------------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}

.empty-state .empty-icon {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--off-white);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  margin-bottom: 16px;
  border: 1px dashed var(--border);
}

.empty-state .empty-icon svg {
  width: 32px;
  height: 32px;
}

.empty-state h3 {
  margin: 0 0 6px;
  color: var(--navy);
  font-size: 16px;
}

.empty-state p {
  margin: 0 0 16px;
  font-size: 13.5px;
  max-width: 360px;
}

/* --------------------------------- Utilities --------------------------------- */

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-12 { margin-bottom: 12px; }
.mb-18 { margin-bottom: 18px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.w-full { width: 100%; }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.info-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.info-item {
  background: var(--off-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.info-item .info-label {
  font-size: 11.5px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.info-item .info-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  position: relative;
  padding: 0 0 22px 26px;
  border-right: 2px solid var(--border);
  margin-right: 8px;
}

.timeline-item:last-child {
  border-color: transparent;
  padding-bottom: 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  right: -7px;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--white);
  box-shadow: 0 0 0 2px var(--gold);
}

.timeline-title {
  font-weight: 700;
  color: var(--navy);
  font-size: 14px;
  margin-bottom: 2px;
}

.timeline-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.timeline-body {
  font-size: 13.5px;
  color: var(--ink);
  background: var(--off-white);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.chat-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.7;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}

.chat-bubble.user {
  background: var(--navy);
  color: var(--white);
  margin-inline-start: auto;
  border-bottom-left-radius: 4px;
}

.chat-bubble.assistant {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--ink);
  margin-inline-end: auto;
  border-bottom-right-radius: 4px;
}

.chat-bubble.out {
  background: var(--gold);
  color: #fff;
  margin-inline-start: auto;
  border-bottom-left-radius: 4px;
}

.chat-bubble.in {
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--ink);
  margin-inline-end: auto;
  border-bottom-right-radius: 4px;
}

.chat-meta {
  font-size: 11px;
  opacity: 0.7;
  margin-top: 4px;
}

.pagination-wrap {
  display: flex;
  justify-content: center;
  margin-top: 24px;
}

.pagination-wrap nav > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.pagination-wrap a,
.pagination-wrap span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--navy);
  border: 1px solid var(--border);
  background: var(--white);
}

.pagination-wrap a:hover {
  background: var(--navy);
  color: var(--white);
}

/* --------------------------------- Guest / Login --------------------------------- */

.guest-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #e8ecf0;
}

.guest-card {
  width: 100%;
  max-width: 420px;
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  padding: 36px 32px;
  animation: fadeIn 420ms ease both;
}

.guest-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  text-align: center;
}

.guest-brand .brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 16px;
}

.guest-brand .brand-mark svg {
  width: 32px;
  height: 32px;
}

.guest-brand h1 {
  font-size: 19px;
  color: var(--navy);
  margin: 0;
}

.guest-brand p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}

.guest-footer {
  text-align: center;
  margin-top: 22px;
  font-size: 12px;
  color: var(--muted);
}

.install-brand h1 {
  color: var(--navy) !important;
}

.install-brand p {
  color: var(--muted) !important;
}

/* --------------------------------- Installer --------------------------------- */

.install-shell {
  min-height: 100vh;
  padding: 40px 20px;
  background: #e8ecf0;
}

.install-wrap {
  max-width: 760px;
  margin: 0 auto;
}

.install-card {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  padding: 32px;
  animation: fadeIn 420ms ease both;
}

.install-steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
  gap: 6px;
}

.install-step {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  position: relative;
  padding-top: 30px;
}

.install-step::before {
  content: attr(data-step);
  position: absolute;
  top: 0;
  right: 50%;
  transform: translateX(50%);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #dfe5ea;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--muted);
}

.install-step.active {
  color: var(--navy);
  font-weight: 700;
}

.install-step.active::before {
  background: var(--gold);
  color: #fff;
  border-color: var(--gold);
}

.install-step.done::before {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--off-white);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  font-size: 13.5px;
}

.check-row .check-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12.5px;
}

.check-status.ok { color: var(--success); }
.check-status.fail { color: var(--danger); }

/* --------------------------------- Responsive --------------------------------- */

/* Tablet */
@media (max-width: 992px) {
  .permission-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main-content {
    padding: 18px 16px 48px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .form-group.full {
    grid-column: 1;
  }
}

/* Mobile / small tablet */
@media (max-width: 768px) {
  body {
    background-attachment: scroll;
    font-size: 15px;
  }

  .topbar-inner {
    padding: 10px 12px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .brand {
    flex: 1;
    min-width: 0;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 9px;
  }

  .brand-mark svg {
    width: 20px;
    height: 20px;
  }

  .brand-title {
    font-size: 13px;
    max-width: 42vw;
  }

  .brand-sub {
    font-size: 11px;
    max-width: 42vw;
  }

  .topbar-actions {
    gap: 6px;
    margin-inline-start: auto;
  }

  .home-nav-btn {
    width: 40px;
    height: 40px;
    min-height: 40px;
    padding: 8px;
    border-radius: 50%;
    justify-content: center;
  }

  .home-nav-btn span {
    display: none;
  }

  .user-meta {
    display: none;
  }

  .user-chip {
    padding: 4px;
    border-radius: 50%;
    background: transparent;
    border: none;
  }

  .logout-btn span {
    display: none;
  }

  .logout-btn {
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    justify-content: center;
  }

  .main-content {
    padding: 16px 12px 88px;
    overflow-x: hidden;
  }

  .hero-card {
    padding: 18px 16px;
    border-radius: 14px;
  }

  .hero-card-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .hero-title {
    font-size: 20px;
    line-height: 1.35;
  }

  .hero-sub {
    font-size: 13px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .stat-card {
    padding: 14px 12px;
    gap: 10px;
  }

  .stat-value {
    font-size: 22px;
  }

  .stat-label {
    font-size: 12px;
  }

  .module-card {
    padding: 14px 12px;
    min-height: 0;
  }

  .module-card h3 {
    font-size: 14px;
  }

  .module-card p {
    font-size: 12px;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .page-header-actions {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-header-actions .btn {
    flex: 1 1 calc(50% - 4px);
    justify-content: center;
    min-height: 42px;
  }

  .card,
  .card-pad {
    border-radius: 12px;
  }

  .card-pad {
    padding: 16px 14px;
  }

  .btn {
    min-height: 42px;
    padding: 10px 14px;
    font-size: 14px;
  }

  .btn-sm {
    min-height: 36px;
  }

  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .form-actions .btn {
    width: 100%;
  }

  input,
  select,
  textarea {
    font-size: 16px !important; /* يمنع زوم iOS */
    min-height: 44px;
  }

  textarea {
    min-height: 110px;
  }

  .table-wrap {
    margin: 0 -4px;
    padding-bottom: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table.data-table {
    min-width: 640px;
    font-size: 13px;
  }

  table.data-table thead th,
  table.data-table tbody td {
    padding: 10px 12px;
    white-space: nowrap;
  }

  .section-title {
    flex-wrap: wrap;
    gap: 10px;
  }

  .install-card {
    padding: 20px 14px;
  }

  .install-step {
    font-size: 0;
  }

  .guest-card {
    padding: 24px 18px;
    margin: 12px;
    width: auto;
  }

  .chat-layout,
  .whatsapp-layout {
    flex-direction: column;
  }

  .alert {
    padding: 12px 14px;
    font-size: 13px;
  }
}

/* Phones */
@media (max-width: 480px) {
  .permission-grid {
    grid-template-columns: 1fr;
  }

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

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

  .stat-icon {
    width: 36px;
    height: 36px;
  }

  .page-header-actions .btn {
    flex: 1 1 100%;
  }

  .brand-sub {
    display: none;
  }
}

/* Large desktop */
@media (min-width: 1200px) {
  .main-content {
    padding-inline: 28px;
  }
}

/* Safe areas (notch phones) */
@supports (padding: max(0px)) {
  .topbar-inner {
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .main-content {
    padding-bottom: max(48px, env(safe-area-inset-bottom));
  }
}


/* Brand link */
.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
}
.brand-mark {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.02em;
}

/* About page */
.about-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 16px;
}
.about-hero {
  grid-column: 1 / -1;
}
.about-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}
.about-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
}
.about-brand h2 {
  margin: 0;
  color: var(--navy);
  font-size: 22px;
}
.about-brand p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.about-lead {
  margin: 0;
  color: var(--ink);
  line-height: 1.7;
  max-width: 70ch;
}
.about-section-title {
  margin: 0 0 14px;
  color: var(--navy);
  font-size: 16px;
}
.about-dl {
  margin: 0 0 16px;
  display: grid;
  gap: 12px;
}
.about-dl div {
  display: grid;
  gap: 2px;
}
.about-dl dt {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.about-dl dd {
  margin: 0;
  font-size: 15px;
  color: var(--navy);
  font-weight: 700;
}
.about-wa {
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.about-version {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(63, 122, 107, 0.14);
  color: var(--navy);
  font-weight: 800;
}

/* Unified dashboard */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.workboard {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  margin-top: 4px;
}

.workboard > .card {
  min-width: 0;
}

.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.72);
}
.app-footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 24px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.app-footer-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--navy);
  font-size: 13px;
}
.app-footer-brand span {
  color: var(--muted);
  font-weight: 600;
}
.app-footer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  font-size: 12.5px;
  color: var(--muted);
}
.app-footer-meta a {
  color: var(--navy);
  font-weight: 700;
  text-decoration: none;
}
.app-footer-meta a:hover {
  text-decoration: underline;
}

@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .module-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

@media (max-width: 992px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .workboard {
    grid-template-columns: 1fr;
  }
  .main-content {
    padding: 18px 16px 48px;
  }
}

@media (max-width: 768px) {
  .about-grid {
    grid-template-columns: 1fr;
  }
  .back-row {
    position: sticky;
    top: 56px;
    z-index: 40;
    padding: 4px 0 8px;
    background: linear-gradient(180deg, rgba(238,241,244,0.96) 60%, transparent);
  }
  .btn-back {
    min-height: 42px;
    padding: 10px 16px;
    font-size: 14px;
    box-shadow: var(--shadow-sm);
  }
  .form-grid[style*="1.4fr"] {
    grid-template-columns: 1fr !important;
  }
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .stat-card {
    padding: 12px 10px;
    gap: 10px;
  }
  .stat-icon {
    width: 38px;
    height: 38px;
  }
  .stat-value {
    font-size: 18px;
  }
  .stat-label {
    font-size: 11px;
  }
  .module-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .module-card {
    min-height: 0;
    padding: 14px 12px;
    gap: 8px;
  }
  .module-icon {
    width: 40px;
    height: 40px;
  }
  .module-card h3 {
    font-size: 14px;
  }
  .module-card p {
    font-size: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .workboard {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .section-title {
    margin: 16px 0 10px;
  }
  .hero-card {
    margin-bottom: 14px;
    padding: 18px 16px;
  }
  .app-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
  .module-grid {
    grid-template-columns: 1fr;
  }
  .module-card {
    min-height: 0;
  }
  .module-card p {
    -webkit-line-clamp: 3;
  }
}

