@import url('fonts.css');

:root {
  color-scheme: light;
  --primary: #dc2626;
  --primary-hover: #b91c1c;
  --primary-light: #fef2f2;
  --primary-dark: #991b1b;
  --accent: #e11d48;
  --navy: #350f16;
  --navy-surface: #501923;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;
  --radius: 18px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.05);
  --shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.04), 0 8px 10px -6px rgba(15, 23, 42, 0.03);
  --shadow-hover: 0 20px 35px -10px rgba(220, 38, 38, 0.12), 0 10px 15px -5px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: radial-gradient(at 0% 0%, rgba(220, 38, 38, 0.04) 0px, transparent 50%), radial-gradient(at 100% 0%, rgba(225, 29, 72, 0.03) 0px, transparent 50%), var(--bg);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

button, input, select, textarea {
  font-family: inherit;
}

img {
  max-width: 100%;
}

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

/* Sidebar Styling */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 270px;
  background: var(--navy);
  color: #e2e8f0;
  padding: 24px 16px;
  z-index: 40;
  overflow-y: auto;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 4px 0 25px rgba(15, 23, 42, 0.15);
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.rtl .sidebar {
  inset: 0 0 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 4px 8px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 20px;
}

.brand-mark, .auth-brand .brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #fff;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  box-shadow: 0 8px 20px rgba(220, 38, 38, 0.35);
  flex-shrink: 0;
}

.brand strong {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f8fafc;
  letter-spacing: -0.01em;
}

.brand small, .auth-brand span {
  display: block;
  color: #94a3b8;
  font-size: 0.78rem;
  font-weight: 500;
}

.nav-section {
  margin: 22px 10px 8px;
  color: #64748b;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #94a3b8;
  padding: 11px 14px;
  border-radius: 12px;
  margin: 4px 0;
  font-size: 0.91rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  transform: translateX(3px);
}

.rtl .nav-link:hover {
  transform: translateX(-3px);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(220, 38, 38, 0.9), rgba(185, 28, 28, 0.85));
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.3);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Main & Topbar */
.main {
  margin-left: 270px;
  min-height: 100vh;
  flex: 1;
  width: calc(100% - 270px);
}

.rtl .main {
  margin-left: 0;
  margin-right: 270px;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.82);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: none;
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text);
}

.page-heading h1 {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--text);
}

.page-heading p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 500;
}

/* Search Bar */
.top-search {
  position: relative;
  display: block;
}

.top-search input {
  width: 240px;
  margin: 0;
  min-height: 42px;
  background: var(--border-light);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 14px 9px 38px;
  font-size: 0.86rem;
  color: var(--text);
  transition: all 0.2s ease;
}

.top-search input:focus {
  background: var(--surface);
  border-color: rgba(220, 38, 38, 0.4);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
  width: 280px;
}

.top-search::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
  z-index: 2;
}

/* Icon Buttons */
.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.icon-button:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: rgba(220, 38, 38, 0.3);
  transform: translateY(-1px);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.notification-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 100px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  font-size: 0.68rem;
  font-weight: 800;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
}

/* User Menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 4px 4px;
  border-radius: 12px;
  transition: background 0.2s ease;
}

.user-menu:hover {
  background: var(--border-light);
}

.user-dropdown {
  position: relative;
}

.user-dropdown summary {
  cursor: pointer;
  list-style: none;
}

.user-dropdown summary::-webkit-details-marker {
  display: none;
}

.user-dropdown summary:focus-visible,
.user-dropdown-panel a:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.user-menu-chevron {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
}

.user-dropdown[open] .user-menu-chevron {
  transform: rotate(180deg);
}

.user-dropdown-panel {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  z-index: 60;
}

.user-dropdown-panel a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
}

.user-dropdown-panel a:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.user-meta strong {
  font-size: 0.88rem;
  font-weight: 700;
  display: block;
  color: var(--text);
  line-height: 1.2;
}

.user-meta span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

/* Main Content Area */
.content {
  padding: 32px;
  max-width: 1700px;
  margin: 0 auto;
}

.grid {
  display: grid;
  gap: 22px;
}

.grid.cards-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.grid.cards-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Cards & Elevated Containers */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.card-header h2, .card-header h3 {
  font-size: 1.08rem;
  font-weight: 800;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.01em;
}

.card-body {
  padding: 24px;
}

/* Stat Cards */
.stat-card {
  padding: 22px 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.stat-card .label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .value {
  font-size: 1.75rem;
  font-weight: 800;
  margin-top: 6px;
  color: var(--text);
  letter-spacing: -0.02em;
}

.stat-card .sub {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 500;
}

.stat-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 1.35rem;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.stat-card:hover .stat-icon {
  transform: scale(1.08);
}

.stat-icon svg {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stat-icon.success {
  background: var(--success-bg);
  color: var(--success);
}
.stat-icon.warning {
  background: var(--warning-bg);
  color: var(--warning);
}
.stat-icon.danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.stat-icon.info {
  background: var(--info-bg);
  color: var(--info);
}

/* Buttons */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.toolbar-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  transform: translateY(-2px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.32);
}

.btn-primary:hover {
  box-shadow: 0 8px 22px rgba(220, 38, 38, 0.45);
}

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

.btn-secondary:hover {
  background: var(--bg);
  border-color: #cbd5e1;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-warning {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-sm {
  padding: 7px 12px;
  font-size: 0.78rem;
  border-radius: 9px;
}

.btn-block {
  width: 100%;
}

/* Modern Tables */
.table-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--radius) var(--radius);
}

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

.table th {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--bg);
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.rtl .table th {
  text-align: right;
}

.table th, .table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.table td {
  font-size: 0.88rem;
  color: var(--text);
  font-weight: 500;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tr:hover td {
  background: var(--border-light);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

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

.badge-success {
  background: #dcfce7;
  color: #15803d;
}

.badge-warning {
  background: #fef3c7;
  color: #b45309;
}

.badge-danger {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-info {
  background: #e0f2fe;
  color: #0369a1;
}

.badge-neutral {
  background: var(--border-light);
  color: #475569;
}

/* Form Styling */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

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

.form-grid .span-2 {
  grid-column: span 2;
}

.form-grid .span-3 {
  grid-column: 1 / -1;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  min-height: 44px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.15);
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.check-row input {
  width: auto;
  min-height: auto;
  margin: 0;
  accent-color: var(--primary);
}

.field-help, .help-text {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 6px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  padding: 24px;
  overflow: auto;
}

.modal.open {
  display: grid;
  place-items: center;
}

.modal-dialog {
  width: min(850px, 100%);
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 25px 70px rgba(15, 23, 42, 0.25);
  margin: auto;
  overflow: hidden;
  border: 1px solid var(--border);
}

.modal-header, .modal-footer {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.modal-header {
  border-bottom: 1px solid var(--border-light);
}

.modal-footer {
  border-top: 1px solid var(--border-light);
  justify-content: flex-end;
  background: var(--bg);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-body {
  padding: 24px;
}

.modal-close {
  border: 0;
  background: transparent;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.2s ease;
}

.modal-close:hover {
  color: var(--text);
}

/* Alerts */
.alert {
  padding: 14px 18px;
  border-radius: 14px;
  margin-bottom: 20px;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.alert-danger {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
}

/* Pagination */
.pagination {
  display: flex;
  gap: 8px;
  padding: 18px 0;
}

.pagination a {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  color: var(--text);
  font-weight: 600;
  transition: all 0.2s ease;
}

.pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination a.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

/* Auth Screens */
.auth-page {
  min-height: 100vh;
  background: radial-gradient(ellipse at top left, rgba(220, 38, 38, 0.18), transparent 50%), radial-gradient(ellipse at bottom right, rgba(225, 29, 72, 0.15), transparent 50%), linear-gradient(135deg, #f8fafc 0%, #edf2f7 100%);
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.auth-shell, .install-shell {
  width: min(450px, 100%);
}

.install-shell {
  width: min(800px, 100%);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 24px;
}

.auth-brand strong {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-card {
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: 24px;
  padding: 36px;
  box-shadow: 0 25px 65px rgba(15, 23, 42, 0.12);
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-card > p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.auth-card label {
  margin-bottom: 16px;
}

/* Lists & Analytics */
.attention-list {
  display: grid;
  gap: 12px;
}

.attention-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  background: var(--bg);
  border-radius: 14px;
  transition: all 0.2s ease;
}

.attention-item:hover {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.attention-item .title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

.attention-item .meta {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

/* Analytics Specifics */
.analytics-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.analytics-intro h2 {
  margin: 4px 0 2px;
  font-size: 1.45rem;
  font-weight: 800;
}

.analytics-eyebrow {
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.analytics-stat .value {
  font-size: 1.85rem;
  font-weight: 800;
}

.analytics-grid {
  display: grid;
  gap: 22px;
  margin-top: 22px;
}

.analytics-grid-primary {
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.85fr);
}

.analytics-grid-secondary {
  grid-template-columns: minmax(0, 1.25fr) minmax(340px, 1fr);
}

.line-chart {
  width: 100%;
  height: 300px;
  position: relative;
}

.donut-layout {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(130px, 1fr);
  gap: 26px;
  align-items: center;
  min-height: 270px;
}

.donut-chart {
  --donut-fill: #e2e8f0;
  width: min(190px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--donut-fill);
  display: grid;
  place-items: center;
  position: relative;
  margin: auto;
}

.donut-chart:after {
  content: "";
  position: absolute;
  width: 62%;
  height: 62%;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.06);
}

.donut-chart > div {
  position: relative;
  z-index: 1;
  display: grid;
  text-align: center;
}

.donut-chart strong {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
}

.donut-chart span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.chart-legend {
  display: grid;
  gap: 12px;
}

.legend-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.84rem;
}

.legend-key {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--legend-colour);
}

.usage-chart {
  display: grid;
  gap: 18px;
  min-height: 270px;
  align-content: center;
}

.usage-row {
  display: grid;
  gap: 8px;
}

.usage-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--muted);
}

.usage-meta strong {
  color: var(--text);
}

.usage-track {
  height: 10px;
  background: var(--border-light);
  border-radius: 999px;
  overflow: hidden;
}

.usage-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #dc2626, #b91c1c);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Media Queries */
@media (max-width: 1150px) {
  .grid.cards-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-grid-primary, .analytics-grid-secondary { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .sidebar { transform: translateX(-105%); box-shadow: 0 15px 45px rgba(0,0,0,0.3); }
  .rtl .sidebar { transform: translateX(105%); }
  .sidebar.open { transform: translateX(0); }
  .main, .rtl .main { margin: 0; width: 100%; }
  .menu-toggle { display: block; }
  .topbar { padding: 0 20px; }
  .content { padding: 20px 16px; }
  .user-meta { display: none; }
  .grid.cards-3, .grid.two { grid-template-columns: 1fr; }
  .top-search { display: none; }
}

@media (max-width: 560px) {
  .grid.cards-4 { grid-template-columns: 1fr; }
  .form-grid, .form-grid.two { grid-template-columns: 1fr; }
  .auth-card { padding: 24px 20px; }
  .content { padding: 16px 12px; }
  .card-header, .card-body { padding: 18px 16px; }
}

.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }

/* Shared appearance controls for every signed-in role. */
.theme-toggle { white-space: nowrap; }
.notification-item { display: flex; align-items: center; gap: 16px; padding: 20px; border-bottom: 1px solid var(--border-light); }
.notification-item:last-child { border-bottom: 0; }
.notification-item h4 { margin: 0 0 6px; }
.notification-item p { margin: 0 0 8px; }
.notification-item time, .notification-icon { color: var(--muted); }
.notification-item.unread { background: var(--primary-light); }
.notification-item.unread .notification-icon { color: var(--primary); }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 3; }
.chart-point { fill: var(--primary); stroke: var(--surface); stroke-width: 2; }
.chart-area { fill: url(#companyGrowthArea); }
.chart-grid-line { stroke: var(--border); }
.chart-axis-label { fill: var(--muted); font-size: 12px; }
.login-toast {
  position: fixed;
  inset-block-start: 92px;
  inset-inline-end: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 20px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-hover);
}
.toast-close { background: transparent; border: 0; color: inherit; font-size: 24px; cursor: pointer; padding: 4px 8px; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #f87171;
  --primary-hover: #fca5a5;
  --primary-light: #451a22;
  --primary-dark: #fecaca;
  --bg: #111113;
  --surface: #202024;
  --text: #f4f4f5;
  --muted: #a1a1aa;
  --border: #45454e;
  --border-light: #2c2c32;
  --navy: #210d13;
  --navy-surface: #35141e;
  --success-bg: #12372c;
  --warning-bg: #422c12;
  --danger-bg: #451a22;
  --info-bg: #172c46;
}
[data-theme="dark"] .topbar { background: rgba(32,32,36,.95); }
[data-theme="dark"] .notification-dot { border-color: var(--surface); }
[data-theme="dark"] .btn-secondary:hover { border-color: var(--muted); }
[data-theme="dark"] .alert-success, [data-theme="dark"] .badge-success { background: var(--success-bg); color: #6ee7b7; border-color: #25634f; }
[data-theme="dark"] .alert-danger, [data-theme="dark"] .badge-danger { background: var(--danger-bg); color: #fca5a5; border-color: #81313d; }
[data-theme="dark"] .alert-warning, [data-theme="dark"] .badge-warning { background: var(--warning-bg); color: #fcd34d; border-color: #765328; }
[data-theme="dark"] .alert-info, [data-theme="dark"] .badge-info { background: var(--info-bg); color: #93c5fd; border-color: #355a87; }
[data-theme="dark"] .badge-secondary { background: var(--border-light); color: var(--muted); }
@media (max-width: 560px) {
  .topbar { height: auto; min-height: 80px; flex-wrap: wrap; gap: 10px; padding: 12px; }
  .topbar-right { flex-wrap: wrap; gap: 8px; }
  .theme-toggle { padding: 8px 10px; }
}

/* RR-inspired RentalFlow presentation. Shared by every existing role and form. */
.avatar { background: #c8a969; color: #122e32; box-shadow: none; }
:root {
  --primary: #806026;
  --primary-hover: #654a1a;
  --primary-light: #f3ead7;
  --primary-dark: #5d461d;
  --accent: #c8a969;
  --navy: #122e32;
  --navy-surface: #1c3c40;
  --bg: #f7f4ed;
  --surface: #ffffff;
  --text: #122e32;
  --muted: #627475;
  --border: #dddfd6;
  --border-light: #eceee6;
  --shadow-hover: 0 16px 36px -16px rgba(18,46,50,.18);
}
body { background: var(--bg); }
.brand-mark, .auth-brand .brand-mark {
  background: #c8a969;
  color: #122e32;
  box-shadow: none;
  font-family: var(--font-heading);
}
.sidebar { background: var(--navy); }
.nav-link.active { background: #c8a969; color: #122e32; box-shadow: none; }
.nav-link:hover { background: #ffffff12; color: #fff; }
.nav-link.active:hover { background: #d6b97b; color: #122e32; }
.nav-link.active .nav-icon { color: #122e32; }
.topbar { background: var(--surface); border-bottom-color: var(--border); }
.page-heading h1, .auth-card h1 {
  font-family: var(--font-heading);
  font-weight: 500;
  letter-spacing: -.025em;
}
.page-heading h1 { font-size: clamp(1.55rem, 2.5vw, 2rem); }
.card { border-color: var(--border); box-shadow: 0 5px 20px rgba(18,46,50,.035); }
.card-header { border-bottom-color: var(--border-light); }
.btn { border-radius: 24px; }
.btn-primary {
  background: #c8a969;
  border-color: #c8a969;
  color: #122e32;
  box-shadow: none;
}
.btn-primary:hover { background: #d7ba7d; border-color: #d7ba7d; color: #122e32; box-shadow: none; }
.btn-primary:focus-visible, a:focus-visible, button:focus-visible { outline: 3px solid #997538; outline-offset: 3px; }
input:focus, select:focus, textarea:focus { border-color: #a5864b; box-shadow: 0 0 0 3px rgba(200,169,105,.18); }
.kpi-bar > span, .usage-track span { background: #c8a969; }
.auth-page {
  background: linear-gradient(90deg,rgba(9,35,39,.86),rgba(9,35,39,.48)),url('../img/rr-hero.jpg') center/cover fixed;
  min-height: 100vh;
  padding: 40px 20px;
}
.auth-shell { width: min(100%,480px); }
.auth-shell.registration-shell { width: min(100%, 720px); }
.registration-brand { text-decoration: none; }
.registration-card .form-grid { gap: 0 20px; }
.registration-card input, .registration-card select { min-width: 0; width: 100%; }
.registration-card .registration-terms { align-items: flex-start; margin: 4px 0 22px; font-size: .9rem; }
.registration-card .registration-terms input { width: 18px; min-width: 18px; height: 18px; margin-top: 3px; }
.registration-card .registration-signin { text-align: center; margin: 24px 0 0; }
.auth-brand strong, .auth-brand span { color: #fff; }
.auth-brand span { opacity: .8; }
.auth-card { background: #fffdf8; color: #122e32; border: 1px solid #e5decd; border-radius: 24px; box-shadow: 0 24px 80px #09232740; }
.auth-card h1 { font-size: 2.3rem; }
.auth-card .login-eyebrow { color: #806026; text-transform: uppercase; letter-spacing: .13em; font-size: .68rem; font-weight: 700; margin-bottom: 16px; }
.login-roles { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 12px; }
.login-roles span { background: #f0eadc; color: #405655; padding: 6px 12px; border-radius: 20px; font-size: .72rem; font-weight: 600; }
:root[data-theme="dark"] {
  --primary: #d8bb7e;
  --primary-hover: #ebd19c;
  --primary-light: #33413b;
  --primary-dark: #e7cd98;
  --bg: #10272b;
  --surface: #19353a;
  --text: #f5f2e9;
  --muted: #b0c1c0;
  --border: #3a5356;
  --border-light: #284348;
  --navy: #0d2226;
  --navy-surface: #19363a;
}
[data-theme="dark"] .topbar { background: var(--surface); }
@media(max-width:560px) {
  .auth-page { padding: 25px 16px; background-attachment: scroll; }
  .auth-card h1 { font-size: 2rem; }
  .page-heading h1 { font-size: 1.55rem; }
}
/* Original RR Properties logo, shared by login and role dashboards. */
.rr-brand-logo { display: block; width: 76px; height: 54px; object-fit: contain; flex-shrink: 0; background: #fff; padding: 4px; border-radius: 8px; }
.auth-brand .rr-brand-logo { width: 92px; height: 68px; }
.brand { gap: 10px; }
.brand strong { font-size: 1rem; }

/* Editorial headings with readable operational controls and figures. */
h1, h2, .auth-card h1, .page-heading h1, .card-header h2 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: 1.25;
}
button, input, select, textarea, table, .btn, .nav-link {
  font-family: var(--font-body);
}
.stat-card .value, .table, input[type="number"] { font-variant-numeric: tabular-nums; }

/* English language names share panel typography in every locale. */
.language-select, .language-select option { font-family: var(--font-body); font-size: .875rem; font-weight: 500; }
/* Responsive panel layout shared by super admin, admin and tenant. */
.main, .content, .grid > *, .form-grid > *, .analytics-grid > *,
.topbar-left, .page-heading, .stat-card > div { min-width: 0; }
.card, .modal-dialog { overflow-wrap: anywhere; }
.table-wrap { max-width: 100%; overscroll-behavior-x: contain; }
.table-wrap:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.sidebar-close, .sidebar-backdrop { display: none; }
.tabs { display: flex; gap: 8px; overflow-x: auto; max-width: 100%; padding-block: 4px 12px; }
.tab { flex-shrink: 0; padding: 10px 16px; border-radius: 12px; }
.tab.active { background: var(--primary-light); color: var(--primary); }
.detail-item { display: flex; justify-content: space-between; gap: 16px; padding-block: 10px; border-bottom: 1px solid var(--border-light); }
.detail-item strong { text-align: end; overflow-wrap: anywhere; min-width: 0; }
.profile-panel { display: flex; align-items: center; gap: 16px; }
.profile-panel > div { min-width: 0; }
.pagination { flex-wrap: wrap; }
@media (max-width: 1350px) {
  .topbar { padding-inline: 20px; gap: 16px; }
  .topbar-right { gap: 10px; }
  .user-meta { display: none; }
  .top-search input, .top-search input:focus { width: 180px; }
}
@media (max-width: 1100px) {
  .sidebar { transform: translateX(-105%); width: min(310px, calc(100vw - 44px)); visibility: hidden; padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); overscroll-behavior-y: contain; }
  .rtl .sidebar { transform: translateX(105%); }
  .sidebar.open, .rtl .sidebar.open { transform: translateX(0); visibility: visible; }
  .main, .rtl .main { margin: 0; width: 100%; }
  .menu-toggle { display: block; flex-shrink: 0; min-width: 44px; min-height: 44px; }
  .sidebar-close { display: block; margin-inline-start: auto; width: 44px; height: 44px; border: 1px solid #ffffff40; border-radius: 12px; background: transparent; color: #fff; font-size: 28px; cursor: pointer; }
  .sidebar-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; background: #0008; z-index: 35; }
  body.navigation-open { overflow: hidden; }
  .topbar { height: auto; min-height: 76px; flex-wrap: wrap; padding-block: 12px; }
  .content { padding: 20px 16px; }
  .grid.two, .grid.cards-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .topbar-left { flex: 1 1 100%; gap: 10px; }
  .topbar-right { width: 100%; flex-wrap: wrap; }
  .top-search { display: block; flex: 1 1 100%; order: 2; }
  .top-search input, .top-search input:focus { width: 100%; font-size: 16px; }
  .user-dropdown, .topbar-right > .user-menu { margin-inline-start: auto; }
  .topbar { position: relative; }
  .icon-button, .avatar { width: 44px; height: 44px; flex-shrink: 0; }
  .language-select { min-height: 44px !important; max-width: 140px; font-size: 16px; }
  input, select, textarea { font-size: 16px; min-width: 0; max-width: 100%; }
  .btn, .tab, .pagination a, .modal-close, .user-dropdown-panel a { min-height: 44px; }
  .btn { white-space: normal; text-align: center; }
  .card-header, .analytics-intro, .attention-item, .notification-item { flex-wrap: wrap; }
  .alert { display: block; overflow-wrap: anywhere; }
  .login-toast { display: flex; }
  .modal { padding: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .modal-dialog { max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain; }
  .modal-header, .modal-body, .modal-footer { padding: 16px; }
  .modal-footer { flex-wrap: wrap; }
  .modal-close { min-width: 44px; flex-shrink: 0; }
  .table th, .table td { padding: 12px; }
  .content { padding-bottom: max(24px, env(safe-area-inset-bottom)); }
}
@media (max-width: 560px) {
  .content { padding-inline: 12px; }
  .form-grid .span-2, .form-grid .span-3 { grid-column: 1 / -1; }
  .grid, .form-grid, .analytics-grid { gap: 16px; }
  .toolbar, .toolbar-group { width: 100%; align-items: stretch; }
  .toolbar-group > input, .toolbar-group > select, .toolbar-group > label { width: 100% !important; min-width: 0 !important; flex: 1 1 100%; }
  .toolbar > .btn, .toolbar-group > .btn { flex: 1 1 auto; }
  .donut-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .line-chart { height: 230px; }
  .stat-card .value { overflow-wrap: anywhere; }
  .receipt-card > .card-body { padding: 18px 16px !important; }
  .receipt-heading, .receipt-total { flex-wrap: wrap; }
  .receipt-heading > div, .receipt-total > div { min-width: 0; }
  .receipt-total { gap: 16px; }
  .detail-item { flex-direction: column; gap: 4px; }
  .detail-item strong { text-align: start; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
@media print {
  .sidebar, .sidebar-backdrop, .topbar, .no-print { display: none !important; }
  .main, .rtl .main { margin: 0; width: 100%; }
  .content { padding: 0; }
}
