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

:root {
  --primary-color: #10b981;
  --primary-dark: #047857;
  --primary-light: #d1fae5;
  --primary-accent: #059669;
  --bg-color: #f4f6f8;
  --panel-bg: #ffffff;
  --text-dark: #1f2937;
  --text-muted: #6b7280;
  --danger-color: #ef4444;
  --danger-light: #fee2e2;
  --warning-color: #f59e0b;
  --warning-light: #fef3c7;
  --success-color: #10b981;
  --success-light: #d1fae5;
  --border-color: #e5e7eb;
  --sidebar-width: 210px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-dark);
  direction: rtl;
  overflow: hidden;
  height: 100vh;
}

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

.setup-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.setup-card {
  background: var(--panel-bg);
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 480px;
  text-align: center;
  border: 1px solid var(--border-color);
  animation: slideUp 0.4s ease-out;
}

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

.setup-card h2 {
  color: var(--primary-dark);
  margin-bottom: 1.5rem;
  font-weight: 800;
  font-size: 1.8rem;
}

.logo-upload-area {
  border: 2px dashed var(--primary-color);
  background-color: #fafdfb;
  border-radius: var(--radius-md);
  padding: 2rem;
  cursor: pointer;
  margin-bottom: 1.5rem;
  transition: all 0.3s ease;
  position: relative;
}

.logo-upload-area:hover {
  background-color: var(--primary-light);
  border-color: var(--primary-dark);
}

.logo-upload-area svg {
  width: 48px;
  height: 48px;
  color: var(--primary-accent);
  margin-bottom: 0.5rem;
}

.logo-preview-img {
  max-width: 120px;
  max-height: 120px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  display: none;
}

.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(135deg, #064e3b 0%, #047857 100%);
  color: white;
  display: flex;
  flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  box-shadow: var(--shadow-lg);
  z-index: 10;
}

.company-brand {
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.company-logo-sidebar {
  width: 35px;
  height: 35px;
  object-fit: contain;
  border-radius: 50%;
  background: white;
  padding: 3px;
  border: 2px solid var(--primary-color);
}

.company-name-sidebar {
  font-weight: 700;
  font-size: 1.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #f9fafb;
}

.sidebar-menu {
  list-style: none;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-grow: 1;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
  color: rgba(255, 255, 255, 0.85);
}

.menu-item:hover, .menu-item.active {
  background-color: rgba(255, 255, 255, 0.15);
  color: white;
}

.menu-item.active {
  background-color: var(--primary-color);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.menu-item svg {
  width: 20px;
  height: 20px;
}

.sidebar-footer {
  padding: 0.7rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
}

.main-layout {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.app-header {
  height: 70px;
  background-color: var(--panel-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.header-title-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.company-logo-header {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: white;
  border: 1px solid var(--border-color);
}

.header-company-name {
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--primary-dark);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0.5rem 1.25rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background-color: var(--primary-accent);
}

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

.btn-secondary:hover {
  background-color: #f9fafb;
  border-color: var(--text-muted);
}

.btn-danger {
  background-color: var(--danger-color);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-warning {
  background-color: var(--warning-color);
  color: white;
}

.btn-warning:hover {
  background-color: #d97706;
}

.page-container {
  flex-grow: 1;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.page {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.page.active {
  display: block;
}

.page:not(#settingsPage).active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page:not(#settingsPage).active .table-container {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

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

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background-color: var(--panel-bg);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.2s ease;
}

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

.stat-details h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.stat-details .value {
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-dark);
}

.stat-icon {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.alerts-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.alert-panel-card {
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: var(--shadow-sm);
}

.alert-panel-card.danger {
  background-color: var(--danger-light);
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-panel-card.warning {
  background-color: var(--warning-light);
  border: 1px solid #fde68a;
  color: #92400e;
}

.alert-panel-card.success {
  background-color: var(--success-light);
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-panel-icon {
  padding: 0.5rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-panel-icon svg {
  width: 24px;
  height: 24px;
}

.alert-panel-details h4 {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.alert-panel-details .value {
  font-size: 1.5rem;
  font-weight: 800;
}

.controls-bar {
  background-color: var(--panel-bg);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 15px;
}

.search-box {
  position: relative;
  width: 100%;
  max-width: 380px;
}

.search-box input {
  width: 100%;
  padding: 0.6rem 2.5rem 0.6rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-box input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-box svg {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

.filters-bar {
  display: flex;
  gap: 8px;
}

.filter-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background-color: white;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background-color: #f9fafb;
  color: var(--text-dark);
}

.filter-btn.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.table-container {
  background-color: var(--panel-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  overflow-x: scroll;
}

.modern-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.9rem;
}

.modern-table th {
  background-color: #fafdfb;
  color: var(--primary-dark);
  font-weight: 700;
  padding: 1rem;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}

.modern-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-dark);
  vertical-align: middle;
}

.modern-table tbody tr {
  transition: background-color 0.2s ease;
}

.modern-table tbody tr:hover {
  background-color: #fafcfb;
}

.modern-table tbody tr:nth-child(even) {
  background-color: #fcfdfd;
}

.link-name {
  color: var(--primary-accent);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s ease;
}

.link-name:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-success {
  background-color: var(--success-light);
  color: #065f46;
}

.badge-danger {
  background-color: var(--danger-light);
  color: #991b1b;
}

.badge-warning {
  background-color: var(--warning-light);
  color: #92400e;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-content {
  background-color: var(--panel-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 750px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-content {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.75rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fafdfb;
}

.modal-header h3 {
  font-weight: 800;
  color: var(--primary-dark);
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  border-radius: 50%;
  transition: background-color 0.2s;
}

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

.modal-close svg {
  width: 24px;
  height: 24px;
}

.modal-body {
  padding: 1.75rem;
  flex-grow: 1;
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background-color: #fafdfb;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: span 2;
}

@media (max-width: 600px) {
  .form-group.full-width {
    grid-column: span 1;
  }
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dark);
}

.form-group input, .form-group select, .form-group textarea {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s ease;
  width: 100%;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.date-input-group {
  display: flex;
  align-items: center;
  gap: 3px;
  direction: ltr;
}
.date-part {
  width: 48px;
  text-align: center;
  font-family: inherit;
  font-size: inherit;
  padding: 0.5rem 0.3rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s;
  background: var(--input-bg, white);
  color: var(--text-dark);
  direction: ltr;
}
.date-part:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}
.date-sep {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 1.1rem;
  user-select: none;
}

.file-upload-container {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  background-color: #fafafa;
}

.file-upload-container:hover {
  border-color: var(--primary-color);
}

.file-upload-container svg {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 1rem;
}

.file-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 8px;
  text-align: center;
  position: relative;
  background: white;
}

.file-card img {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 5px;
}

.file-card-name {
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dark);
}

.file-card-delete {
  position: absolute;
  top: 4px;
  left: 4px;
  background-color: var(--danger-color);
  color: white;
  border: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 10px;
}

.profile-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

.profile-sidebar {
  background-color: #fafdfb;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.profile-avatar {
  width: 90px;
  height: 90px;
  background-color: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.25rem;
  font-size: 2.2rem;
  font-weight: 800;
  border: 3px solid white;
  box-shadow: var(--shadow-md);
}

.profile-name {
  text-align: center;
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary-dark);
  margin-bottom: 0.25rem;
}

.profile-code {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-weight: 600;
}

.profile-info-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-info-item {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #f3f4f6;
  padding-bottom: 8px;
}

.profile-info-item:last-child {
  border-bottom: none;
}

.profile-info-item span.label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 2px;
}

.profile-info-item span.val {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-dark);
}

.profile-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.profile-tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  font-family: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--primary-dark);
}

.tab-btn.active {
  color: var(--primary-accent);
  border-bottom-color: var(--primary-accent);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.installments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.installment-item {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: white;
  transition: box-shadow 0.2s;
}

.installment-item:hover {
  box-shadow: var(--shadow-sm);
}

.installment-details {
  display: flex;
  align-items: center;
  gap: 20px;
}

.inst-number {
  font-weight: 800;
  color: var(--text-muted);
  font-size: 1.1rem;
  background: #f3f4f6;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.inst-meta {
  display: flex;
  flex-direction: column;
}

.inst-amount {
  font-weight: 800;
  color: var(--text-dark);
}

.inst-date {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.docs-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 15px;
}

.doc-item-card {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: white;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}

.doc-item-preview {
  height: 120px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}

.doc-item-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doc-item-preview svg {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}

.doc-item-info {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.doc-item-name {
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.doc-item-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 5px;
}

.lightbox {
  position: fixed;
  inset: 0;
  background-color: rgba(0,0,0,0.85);
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  max-width: 90%;
  max-height: 90vh;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}

.settings-section {
  background: white;
  border-radius: var(--radius-md);
  padding: 2rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.settings-section h2 {
  font-size: 1.3rem;
  color: var(--primary-dark);
  font-weight: 800;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 10px;
}

.backup-controls {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.description-text {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.btn-notification {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid var(--border-color);
  background-color: white;
  color: var(--text-dark);
}

.btn-notification:hover {
  background-color: #f9fafb;
  border-color: var(--text-muted);
}

.notification-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background-color: #22c55e;
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  animation: blink-green 1.2s ease-in-out infinite;
}

@keyframes blink-green {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.85); }
}

#dashboardPage .alerts-board {
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

#dashboardPage .alert-panel-card {
  padding: 0.9rem 1rem;
}

#dashboardPage .alert-panel-details .value {
  font-size: 1.2rem;
}

#dashboardPage .stats-grid {
  grid-template-columns: repeat(5, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

#dashboardPage .stat-card {
  padding: 1rem;
}

#dashboardPage .stat-details .value {
  font-size: 1.3rem;
}

#dashboardPage .stat-details h3 {
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
}

#dashboardPage .stat-icon {
  padding: 0.5rem;
}

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

#dashboardPage .settings-section {
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

#dashboardPage .settings-section h2 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

#dashboardPage .description-text {
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

@media print {
  body {
    background-color: white !important;
    color: black !important;
    overflow: visible !important;
    height: auto !important;
    direction: rtl !important;
  }
  
  .sidebar, .app-header, .controls-bar, .modal-close, .modal-footer, .btn, .lightbox, .setup-overlay, .tab-btn, .doc-item-actions {
    display: none !important;
  }

  .app-container {
    display: block !important;
    height: auto !important;
    width: auto !important;
  }

  .main-layout {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .page-container {
    padding: 0 !important;
    overflow: visible !important;
  }

  .page {
    display: block !important;
    page-break-after: always;
  }

  .page:last-child {
    page-break-after: avoid;
  }

  .modern-table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  .modern-table th {
    background-color: #f3f4f6 !important;
    color: black !important;
    border: 1px solid #000 !important;
  }

  .modern-table td {
    border: 1px solid #000 !important;
  }

  .print-only-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    border-bottom: 3px double #000;
    padding-bottom: 15px;
    margin-bottom: 30px;
  }

  .print-only-logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
  }

  .print-only-title {
    font-size: 1.8rem;
    font-weight: 800;
  }

  .print-only-date {
    font-size: 0.9rem;
  }
}

.print-only-header {
  display: none;
}

.vivid-number {
  font-weight: 700;
  font-size: 1rem;
  color: #047857;
}

.vivid-number.danger {
  color: #dc2626;
  font-weight: 800;
}

.vivid-number.warning {
  color: #d97706;
}

.vivid-number.success {
  color: #059669;
}

.vivid-number.muted {
  color: var(--text-muted);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--border-color);
  transition: 0.3s;
  border-radius: 26px;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  right: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(-22px);
}

:root.dark-mode {
  --bg-color: #111827;
  --panel-bg: #1f2937;
  --text-dark: #f3f4f6;
  --text-muted: #9ca3af;
  --border-color: #374151;
  --primary-light: #064e3b;
  --danger-light: #450a0a;
  --warning-light: #451a03;
  --success-light: #064e3b;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
}

:root.dark-mode .modern-table th {
  background-color: #111827;
}

:root.dark-mode .modern-table tbody tr:nth-child(even) {
  background-color: #111827;
}

:root.dark-mode .modern-table tbody tr:hover {
  background-color: #1a2332;
}

:root.dark-mode .stat-icon {
  background-color: #374151;
}

:root.dark-mode .alert-panel-card h4,
:root.dark-mode .alert-panel-card .value {
  color: #ffffff;
}

:root.dark-mode .search-box input:focus {
  box-shadow: 0 0 0 3px #065f46;
}

:root.dark-mode .modal-header {
  background-color: #111827;
}

:root.dark-mode .modal-footer {
  background-color: #111827;
}

:root.dark-mode .file-card {
  background: #1f2937;
}

:root.dark-mode .profile-sidebar {
  background-color: #111827;
}

:root.dark-mode .file-upload-container {
  background-color: #111827;
}

:root.dark-mode .doc-item-preview {
  background: #111827;
}

:root.dark-mode .inst-number {
  background: #374151;
  color: #d1d5db;
}

:root.dark-mode .btn-secondary {
  background-color: #374151;
  border-color: #4b5563;
  color: #f3f4f6;
}

:root.dark-mode .btn-secondary:hover {
  background-color: #4b5563;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #065f46;
  color: white;
  padding: 0.85rem 2rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.95rem;
  z-index: 99999;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  text-align: center;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.zoom-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-sm);
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.zoom-indicator:hover {
  border-color: var(--primary-color);
  color: var(--primary-dark);
}

#zoomLevelText {
  min-width: 35px;
  text-align: center;
}

.page-container {
  transition: transform 0.15s ease, width 0.15s ease, height 0.15s ease;
  transform-origin: 50% 50%;
}

.sidebar {
  position: relative;
  transition: width 0.2s ease;
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
  transition: background-color 0.2s;
}

.sidebar-resize-handle:hover,
.sidebar-resize-handle:active {
  background-color: var(--primary-color);
}

.sidebar.collapsed .menu-text {
  display: none;
}

.sidebar.collapsed .company-name-sidebar {
  display: none;
}

.sidebar.collapsed .sidebar-footer .menu-text {
  display: none;
}

.sidebar.collapsed .company-brand {
  justify-content: center;
  padding: 0.75rem 0.25rem;
}

.sidebar.collapsed .sidebar-menu {
  padding: 0.5rem 0.25rem;
}

.sidebar.collapsed .menu-item {
  justify-content: center;
  padding: 0.55rem 0.25rem;
}

.sidebar.collapsed .menu-item svg {
  width: 22px;
  height: 22px;
}

.sidebar.collapsed + .main-layout .app-header .header-title-container {
  margin-right: 0;
}

:root.dark-mode .zoom-indicator {
  background: #1f2937;
  border-color: #374151;
  color: #9ca3af;
}

:root.dark-mode .zoom-indicator:hover {
  border-color: var(--primary-color);
  color: #f3f4f6;
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--text-dark);
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.hamburger-btn svg {
  width: 24px;
  height: 24px;
}
.hamburger-btn:hover {
  background: var(--border-color);
}

.mobile-nav-overlay {
  display: none;
}

@media (max-width: 768px) {
  body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }

  .app-container {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    position: fixed;
    top: 0;
    right: -280px;
    width: 260px !important;
    height: 100vh;
    z-index: 2000;
    transition: right 0.3s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.mobile-open {
    right: 0;
  }

  .sidebar.mobile-open ~ .main-layout .mobile-nav-overlay {
    display: block;
  }

  .sidebar-resize-handle {
    display: none;
  }

  .sidebar.collapsed .menu-text {
    display: inline;
  }
  .sidebar.collapsed .company-name-sidebar {
    display: inline;
  }
  .sidebar.collapsed .sidebar-footer .menu-text {
    display: inline;
  }
  .sidebar.collapsed .company-brand {
    justify-content: flex-start;
    padding: 1rem;
  }
  .sidebar.collapsed .sidebar-menu {
    padding: 0.75rem 0.5rem;
  }
  .sidebar.collapsed .menu-item {
    justify-content: flex-start;
    padding: 0.55rem 0.85rem;
  }

  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .main-layout {
    width: 100%;
    overflow: visible;
  }

  .app-header {
    height: auto;
    min-height: 56px;
    padding: 0.5rem 0.75rem;
    gap: 8px;
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .header-title-container {
    flex: 1;
    min-width: 0;
  }

  .header-company-name {
    font-size: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-actions {
    gap: 6px;
  }

  .header-actions .btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.75rem;
  }

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

  .zoom-indicator {
    display: none;
  }

  .page-container {
    padding: 0.75rem;
    transform: none !important;
    width: 100% !important;
    height: auto !important;
  }

  .page {
    overflow: visible;
  }

  .page:not(#settingsPage).active {
    overflow: visible;
  }
  .page:not(#settingsPage).active .table-container {
    overflow: auto;
  }

  #dashboardPage .alerts-board {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .alerts-board {
    grid-template-columns: 1fr;
  }

  #dashboardPage .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .stat-card {
    padding: 0.75rem;
  }
  .stat-details .value {
    font-size: 1.2rem;
  }
  .stat-icon {
    padding: 0.5rem;
  }
  .stat-icon svg {
    width: 20px;
    height: 20px;
  }

  .controls-bar {
    flex-direction: column;
    padding: 0.75rem;
    gap: 10px;
  }

  .search-box {
    max-width: 100%;
  }

  .filters-bar {
    flex-wrap: wrap;
  }
  .filter-btn {
    font-size: 0.75rem;
    padding: 0.35rem 0.6rem;
  }

  .modern-table {
    font-size: 0.75rem;
  }
  .modern-table th,
  .modern-table td {
    padding: 0.5rem 0.4rem;
    white-space: nowrap;
  }
  .modern-table td:first-child,
  .modern-table th:first-child {
    position: sticky;
    right: 0;
    background: var(--panel-bg);
    z-index: 1;
  }
  .modern-table th:first-child {
    z-index: 2;
  }

  .table-container {
    overflow-x: auto;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-group.full-width {
    grid-column: span 1;
  }

  .modal-content {
    width: 95%;
    max-width: 95%;
    margin: 0.5rem;
    max-height: 95vh;
  }

  .modal-body {
    padding: 1rem;
  }

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

  .profile-sidebar {
    padding: 1rem;
  }

  .profile-tabs {
    overflow-x: auto;
    gap: 0;
  }
  .tab-btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .installment-item {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }

  .installment-item > div:last-child {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .doc-item-card {
    max-width: 160px;
  }

  .docs-gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }

  .backup-controls {
    flex-direction: column;
  }
  .backup-controls .btn {
    width: 100%;
  }

  .settings-section {
    padding: 1rem;
  }

  .setup-card {
    padding: 1.5rem;
    width: 95%;
  }

  .lightbox-content {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  #dashboardPage .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .header-actions .btn-primary {
    padding: 0.35rem 0.5rem;
    font-size: 0.7rem;
  }
  .header-actions .btn-primary svg {
    width: 14px;
    height: 14px;
  }

  .company-logo-header {
    width: 30px;
    height: 30px;
  }

  .stat-details .value {
    font-size: 1rem;
  }
  .stat-details h3 {
    font-size: 0.7rem;
  }

  .modern-table {
    font-size: 0.7rem;
  }
  .modern-table th,
  .modern-table td {
    padding: 0.4rem 0.3rem;
  }
}
