:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --primary: #0f7bff;
  --primary-hover: #0c6ce0;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #4b5563;
  --surface: #fafafa;
}

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

html,
body {
  height: 100%;
  direction: rtl;
  text-align: right;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

ul {
  list-style: none;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

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

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
}

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

.sidebar {
  width: 240px;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  z-index: 10;
}

.sidebar-header {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.4;
}

.sidebar-subtitle {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #d1d5db;
  transition: all 0.12s ease;
  font-size: 14px;
}

.sidebar-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.sidebar-link.active {
  background: rgba(59, 130, 246, 0.25);
  color: #ffffff;
}

.sidebar-footer {
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.02);
}

.topbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.content {
  padding: 20px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  overflow: hidden;
}

.card-header {
  padding: 14px 18px 8px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-body {
  padding: 14px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-footer {
  padding: 10px 18px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

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

.grid-2 {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

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

.quick-actions {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 14px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  text-align: center;
}

.quick-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.14);
}

.quick-blue {
  background: #0f7bff;
}

.quick-green {
  background: #16a34a;
}

.quick-orange {
  background: #f59e0b;
}

.quick-purple {
  background: #7c3aed;
}

.quick-red {
  background: #dc2626;
}

.quick-gray {
  background: #4b5563;
}

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

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}

.stat-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
}

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

.stat-icon.blue {
  background: rgba(15, 123, 255, 0.1);
  color: var(--primary);
}

.stat-icon.green {
  background: rgba(22, 163, 74, 0.1);
  color: var(--success);
}

.stat-icon.orange {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.stat-icon.red {
  background: rgba(220, 38, 38, 0.1);
  color: var(--danger);
}

.stat-icon.gray {
  background: rgba(75, 85, 99, 0.1);
  color: var(--info);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.12s ease;
  white-space: nowrap;
  line-height: 1.2;
}

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

.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
  border-radius: 7px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 6px;
}

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

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

.btn-success {
  background: var(--success);
  color: #ffffff;
}

.btn-success:hover {
  filter: brightness(0.96);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: #f8fafc;
}

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

.btn-danger:hover {
  filter: brightness(0.96);
}

.btn-warning {
  background: var(--warning);
  color: #1f2937;
}

.btn-light {
  background: #f3f4f6;
  color: var(--text);
  border-color: var(--border);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-open {
  background: rgba(15, 123, 255, 0.12);
  color: #0f7bff;
  border-color: rgba(15, 123, 255, 0.25);
}

.badge-inprogress {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.25);
}

.badge-ready {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.25);
}

.badge-delivered {
  background: rgba(107, 114, 128, 0.12);
  color: #374151;
  border-color: rgba(107, 114, 128, 0.25);
}

.badge-cancelled {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.25);
}

.badge-in {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.25);
}

.badge-out {
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.25);
}

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

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

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

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

.input,
.select,
.textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  font-size: 14px;
  outline: none;
  transition: border 0.12s ease, box-shadow 0.12s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: rgba(15, 123, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 123, 255, 0.12);
}

.textarea {
  min-height: 70px;
  resize: vertical;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  min-width: 720px;
}

.table thead {
  background: #f8fafc;
}

.table th,
.table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  vertical-align: middle;
  font-size: 14px;
}

.table th {
  font-weight: 700;
  color: #374151;
  white-space: nowrap;
}

.table tbody tr:hover {
  background: #fafafa;
}

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

.img-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f3f4f6;
}

.img-thumb-lg {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: #f3f4f6;
}

.img-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.img-placeholder svg {
  width: 20px;
  height: 20px;
}

.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.items-start {
  align-items: flex-start;
}

.justify-between {
  justify-content: space-between;
}

.justify-end {
  justify-content: flex-end;
}

.justify-center {
  justify-content: center;
}

.gap-4 {
  gap: 4px;
}

.gap-6 {
  gap: 6px;
}

.gap-8 {
  gap: 8px;
}

.gap-10 {
  gap: 10px;
}

.gap-12 {
  gap: 12px;
}

.gap-14 {
  gap: 14px;
}

.gap-16 {
  gap: 16px;
}

.gap-20 {
  gap: 20px;
}

.wrap {
  flex-wrap: wrap;
}

.column {
  flex-direction: column;
}

.w-full {
  width: 100%;
}

.mono {
  font-variant-numeric: tabular-nums;
}

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

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.text-warning {
  color: var(--warning);
}

.text-sm {
  font-size: 13px;
}

.text-xs {
  font-size: 12px;
}

.font-bold {
  font-weight: 700;
}

.font-extrabold {
  font-weight: 800;
}

.mb-2 {
  margin-bottom: 2px;
}

.mt-2 {
  margin-top: 2px;
}

.mt-6 {
  margin-top: 6px;
}

.mt-10 {
  margin-top: 10px;
}

.p-12 {
  padding: 12px;
}

.p-14 {
  padding: 14px;
}

.p-16 {
  padding: 16px;
}

.pos-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(320px, 0.85fr);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1080px) {
  .pos-layout {
    grid-template-columns: 1fr;
  }
}

.pos-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding: 4px 2px 6px;
}

@media (max-width: 1080px) {
  .pos-list {
    max-height: none;
  }
}

.pos-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.1s ease;
  box-shadow: 0 1px 1px rgba(15, 23, 42, 0.02);
}

.pos-card:hover {
  border-color: rgba(15, 123, 255, 0.45);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.pos-card-img {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f3f4f6;
}

.pos-card-img-placeholder {
  width: 100%;
  aspect-ratio: 1/1;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: #f9fafb;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.pos-card-img-placeholder svg {
  width: 26px;
  height: 26px;
}

.pos-card-name {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  min-height: 36px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pos-card-price {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
}

.pos-card-stock {
  font-size: 11px;
  color: var(--text-muted);
}

.cart {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 140px);
}

@media (max-width: 1080px) {
  .cart {
    max-height: none;
  }
}

.cart-header {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
}

.cart-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #ffffff;
}

.cart-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.cart-item-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-item-price {
  font-size: 12px;
  color: var(--text-muted);
}

.cart-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.qty-control {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.qty-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  color: var(--text);
}

.qty-btn:hover {
  background: #f1f5f9;
}

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

.qty-input {
  width: 44px;
  height: 30px;
  border: none;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  background: #ffffff;
}

.cart-item-subtotal {
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.cart-footer {
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
}

.total-label {
  font-size: 14px;
  color: var(--text);
}

.total-value {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.total-row.grand {
  background: #f1f5f9;
}

.total-row.due {
  background: var(--danger-bg);
}

.total-row.paid {
  background: var(--success-bg);
}

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

.empty-state svg {
  width: 40px;
  height: 40px;
  opacity: 0.85;
}

.alert {
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 14px;
  border: 1px solid transparent;
}

.alert-info {
  background: rgba(15, 123, 255, 0.08);
  color: #0f7bff;
  border-color: rgba(15, 123, 255, 0.2);
}

.alert-success {
  background: var(--success-bg);
  color: #15803d;
  border-color: rgba(22, 163, 74, 0.2);
}

.alert-warning {
  background: var(--warning-bg);
  color: #92400e;
  border-color: rgba(245, 158, 11, 0.25);
}

.alert-danger {
  background: var(--danger-bg);
  color: #b91c1c;
  border-color: rgba(220, 38, 38, 0.2);
}

.filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chips {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.1s ease;
  white-space: nowrap;
}

.chip:hover {
  background: #f8fafc;
}

.chip.active {
  background: rgba(15, 123, 255, 0.1);
  border-color: rgba(15, 123, 255, 0.4);
  color: #0f7bff;
  font-weight: 700;
}

.maintenance-detail {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px 16px;
}

.detail-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #ffffff;
}

.detail-label {
  font-size: 12px;
  color: var(--text-muted);
}

.detail-value {
  font-size: 14px;
  font-weight: 600;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.problem-box {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fafafa;
  white-space: pre-wrap;
  line-height: 1.8;
}

.notes-box {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #ffffff;
  white-space: pre-wrap;
  line-height: 1.8;
}

.summary-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.summary-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 4px;
}

.summary-label {
  font-size: 12px;
  color: var(--text-muted);
}

.summary-value {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.text-left {
  text-align: left;
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .content {
    padding: 14px 12px 20px;
  }
  .topbar {
    padding: 8px 12px;
  }
  .pos-list {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  }
  .table {
    min-width: 640px;
  }
}
