@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

: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: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  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; }
}
