@font-face {
  font-family: system-ui;
  src: local("Segoe UI"), local("Tahoma"), local("Arial");
}
:root {
  --bg: #0f172a;
  --surface: #111827;
  --surface-2: #0b1220;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --primary: #3b82f6;
  --primary-contrast: #ffffff;
  --border: #1f2937;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}
body[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #475569;
  --primary: #2563eb;
  --primary-contrast: #ffffff;
  --border: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
}
* {
  box-sizing: border-box;
}
html, body {
  height: 100%;
}
body {
  margin: 0;
  font-family: system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
}
input, select, button {
  font-family: inherit;
  color: var(--text);
}
input, select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}
input::placeholder {
  color: var(--muted);
}
button {
  border: none;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform 0.06s ease, opacity 0.2s ease, background 0.2s ease;
}
button:active {
  transform: scale(0.98);
}
.btn {
  background: var(--surface-2);
  color: var(--text);
}
.btn.primary {
  background: var(--primary);
  color: var(--primary-contrast);
}
.btn.secondary {
  background: transparent;
  border: 1px solid var(--border);
}
.btn.full {
  width: 100%;
}
.icon-btn {
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: 10px;
}
.sidebar {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  height: 100%;
  width: 280px;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 30;
}
.sidebar.collapsed {
  width: 80px;
}
.sidebar.collapsed .brand-title {
  display: none;
}
.sidebar.collapsed .menu-label {
  display: none;
}
.sidebar.collapsed .menu-item {
  justify-content: center;
  gap: 0;
}
.sidebar.collapsed .menu-item .mi-icon {
  margin-inline-start: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-block-end: 1px solid var(--border);
}
.brand-icon {
  font-size: 22px;
}
.brand-title {
  font-weight: 600;
}
.menu {
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}
.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
}
.menu-item .mi-icon {
  margin-inline-start: 6px;
}
.menu-item:hover {
  background: var(--surface-2);
}
.menu-item.active {
  background: var(--primary);
  color: var(--primary-contrast);
}
.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-block-start: 1px solid var(--border);
}
.main {
  margin-inline-start: 280px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}
.sidebar.collapsed + .main {
  margin-inline-start: 80px;
}
.topbar {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--surface);
  border-block-end: 1px solid var(--border);
  z-index: 20;
}
#mobileMenu {
  display: none;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.form-grid.full-width {
  grid-template-columns: 1fr;
}
.top-actions .user {
  margin-inline-start: auto;
}
.btn .mi-icon {
  margin-inline-start: 6px;
}
.mi-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  font-size: 18px;
}
.user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
}
.avatar {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface);
}
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  border: 1px solid var(--border);
}
.user-dropdown {
  position: absolute;
  inset-inline-end: 0;
  inset-block-start: calc(100% + 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  min-width: 200px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 60;
  overflow: hidden;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  color: var(--text);
  padding: 10px 12px;
  border: none;
  text-align: start;
}
.dropdown-item:hover {
  background: var(--surface-2);
}
.content {
  padding: 18px;
}
.auth .sidebar, .auth .topbar {
  display: none;
}
.auth .main {
  margin-inline-start: 0;
}
.login-wrapper {
  display: grid;
  place-items: center;
  min-height: 70vh;
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  width: 420px;
  max-width: 95vw;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}
.card-title {
  color: var(--muted);
  margin-bottom: 8px;
}
.card-value {
  font-size: 24px;
  font-weight: 700;
}
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.input-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}
.input-group input {
  background: transparent;
  border: none;
  padding: 6px 0;
}
.input-icon .mi-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
}
.table-wrapper {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
}
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}
.table th {
  text-align: start;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.table th[data-sort] {
  color: var(--muted);
}
.table th.th-active {
  color: var(--text);
}
.sort-indicator {
  display: inline-flex;
  align-items: center;
  margin-inline-start: 6px;
  opacity: 0.8;
}
.sort-indicator .mi-icon {
  width: 14px;
  height: 14px;
}
.route-inline .mi-icon {
  width: 16px;
  height: 16px;
  margin: 0 6px;
  vertical-align: middle;
}
.table th, .table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.table th {
  text-align: start;
  background: var(--surface-2);
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tr:hover td {
  background: var(--surface-2);
}
.view.hidden {
  display: none;
}
.form-grid {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 12px;
}
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}
.form-row label {
  color: var(--muted);
  font-size: 13px;
}
.form-actions {
  display: flex;
  gap: 10px;
}
.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 50;
}
.modal.hidden {
  display: none;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.modal-content {
  position: relative;
  width: 700px;
  max-width: 95vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-weight: 600;
}
.modal-body {
  padding: 14px;
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.placeholder {
  display: grid;
  place-items: center;
  height: 200px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
}
.badge.success {
  background: rgba(16,185,129,0.15);
  color: var(--success);
}
.badge.warning {
  background: rgba(245,158,11,0.15);
  color: var(--warning);
}
.badge.danger {
  background: rgba(239,68,68,0.15);
  color: var(--danger);
}
.toast-container {
  position: fixed;
  inset-inline-start: 16px;
  inset-block-start: 16px;
  display: grid;
  gap: 8px;
  z-index: 70;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
}
.toast.error {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239,68,68,0.10);
}
.toast .mi-icon {
  width: 18px;
  height: 18px;
}
.toast .toast-close {
  margin-inline-start: auto;
  background: transparent;
  border: none;
}
.print-area.hidden { display: none; }
@media print {
  body * { visibility: hidden !important; }
  .print-area, .print-area * { visibility: visible !important; }
  .print-area {
    position: absolute;
    inset: 0;
    padding: 24px;
    background: #fff;
    color: #000;
  }
}
@media (max-width: 1024px) {
  .cards {
    grid-template-columns: repeat(2, 1fr);
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 640px) {
  #mobileMenu {
    display: inline-flex;
  }
  .sidebar {
    transform: translateX(0);
  }
  .sidebar.hidden {
    transform: translateX(100%);
  }
  .main {
    margin-inline-start: 0;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .top-actions {
    gap: 6px;
  }
  .table {
    min-width: 600px;
  }
}
