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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f2f5;
  color: #333;
  direction: rtl;
}

header {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: white;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
  font-size: 24px;
  font-weight: 700;
}

header .subtitle {
  font-size: 14px;
  opacity: 0.8;
}

header .header-buttons {
  display: flex;
  gap: 10px;
}

.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 20px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: #4CAF50;
  color: white;
}

.btn-primary:hover {
  background: #388E3C;
  transform: translateY(-1px);
}

.btn-warning {
  background: #ff9800;
  color: white;
}

.btn-warning:hover {
  background: #e68900;
}

.btn-danger {
  background: #f44336;
  color: white;
}

.btn-danger:hover {
  background: #d32f2f;
}

.btn-info {
  background: #2196F3;
  color: white;
}

.btn-info:hover {
  background: #1976D2;
}

.btn-secondary {
  background: #607d8b;
  color: white;
}

.btn-secondary:hover {
  background: #455a64;
}

.btn-success {
  background: #8bc34a;
  color: white;
}

.btn-success:hover {
  background: #689f38;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 30px 0 20px;
  padding-bottom: 10px;
  border-bottom: 3px solid #1a1a2e;
  color: #1a1a2e;
}

.pieces-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.piece-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  transition: transform 0.3s ease;
}

.piece-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}

.piece-card.delivered {
  border: 2px solid #8bc34a;
}

.piece-image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  background: #e0e0e0;
}

.piece-image-placeholder {
  width: 100%;
  height: 220px;
  background: linear-gradient(135deg, #e0e0e0, #f5f5f5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 48px;
}

.piece-info {
  padding: 15px;
}

.piece-info .info-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}

.piece-info .info-row:last-child {
  border-bottom: none;
}

.piece-info .info-label {
  color: #666;
  font-weight: 500;
}

.piece-info .info-value {
  font-weight: 600;
  color: #1a1a2e;
}

.piece-info .info-value .currency {
  font-size: 11px;
  color: #888;
  margin-right: 2px;
}

.profit-boxes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 15px 15px;
}

.profit-box {
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}

.profit-box.ali {
  background: #e3f2fd;
  border: 1px solid #90caf9;
}

.profit-box.baghdad {
  background: #fce4ec;
  border: 1px solid #f48fb1;
}

.profit-box .profit-name {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}

.profit-box.ali .profit-name {
  color: #1565c0;
}

.profit-box.baghdad .profit-name {
  color: #c62828;
}

.profit-box .profit-amount {
  font-size: 18px;
  font-weight: 800;
}

.profit-box.ali .profit-amount {
  color: #1565c0;
}

.profit-box.baghdad .profit-amount {
  color: #c62828;
}

.profit-box .profit-currency {
  font-size: 11px;
  color: #666;
}

.piece-actions {
  padding: 0 15px 15px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.piece-actions .btn {
  flex: 1;
  justify-content: center;
  min-width: 80px;
  font-size: 11px;
  padding: 6px 8px;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.status-badge.reserved {
  background: #fff3e0;
  color: #e65100;
}

.status-badge.delivered {
  background: #e8f5e9;
  color: #2e7d32;
}

/* Modal */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 30px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal h2 {
  margin-bottom: 20px;
  font-size: 22px;
  color: #1a1a2e;
}

.modal .form-group {
  margin-bottom: 20px;
}

.modal .form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
  color: #444;
}

.modal .form-group input,
.modal .form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
  font-family: inherit;
}

.modal .form-group input:focus,
.modal .form-group select:focus {
  outline: none;
  border-color: #4CAF50;
}

.modal .form-group input[type="file"] {
  padding: 8px;
  border: 2px dashed #e0e0e0;
}

.modal .modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 25px;
}

.modal .modal-actions .btn {
  min-width: 100px;
  justify-content: center;
}

.image-preview {
  width: 100%;
  height: 200px;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 15px;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.image-preview .preview-placeholder {
  color: #bbb;
  font-size: 14px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #888;
}

.loading .spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top-color: #1a1a2e;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 15px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 15px;
}

.empty-state h3 {
  font-size: 20px;
  margin-bottom: 8px;
  color: #666;
}

/* Toast notifications */
.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  padding: 14px 24px;
  border-radius: 10px;
  color: white;
  font-weight: 600;
  font-size: 14px;
  z-index: 2000;
  animation: slideIn 0.3s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.toast.success {
  background: #4CAF50;
}

.toast.error {
  background: #f44336;
}

.toast.info {
  background: #2196F3;
}

@keyframes slideIn {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Money received select */
.money-received-info {
  padding: 0 15px 10px;
  font-size: 13px;
}

.money-received-info .received-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-weight: 700;
}

.money-received-info .received-badge.ali {
  background: #e3f2fd;
  color: #1565c0;
}

.money-received-info .received-badge.baghdad {
  background: #fce4ec;
  color: #c62828;
}

/* Login screen */
.login-modal {
  max-width: 360px;
}

.login-modal h2 {
  text-align: center;
}

.login-modal .login-icon {
  font-size: 56px;
  text-align: center;
  margin-bottom: 10px;
}

.login-modal .form-group input[type="password"] {
  text-align: center;
  font-size: 18px;
  letter-spacing: 4px;
}

.login-modal .btn {
  width: 100%;
  justify-content: center;
}

.login-hint {
  text-align: center;
  font-size: 12px;
  color: #aaa;
  margin-top: 10px;
}

/* Floating action button */
.fab-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.fab-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  color: white;
  border: none;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
}

.fab-btn.active {
  transform: rotate(45deg);
}

.fab-popup {
  position: absolute;
  bottom: 68px;
  left: 0;
  background: white;
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  display: none;
  min-width: 200px;
}

.fab-popup.show {
  display: block;
}

.fab-popup-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  white-space: nowrap;
}

.fab-popup-item + .fab-popup-item {
  border-top: 1px solid #f0f0f0;
  margin-top: 4px;
  padding-top: 10px;
}

.fab-popup-label {
  font-weight: 600;
  flex-shrink: 0;
}

.fab-popup-item.ali .fab-popup-label {
  color: #1565c0;
}

.fab-popup-item.baghdad .fab-popup-label {
  color: #c62828;
}

.fab-popup-item.due .fab-popup-label {
  color: #2e7d32;
}

.fab-popup-value {
  font-weight: 800;
  font-size: 16px;
}

.fab-popup-item.ali .fab-popup-value {
  color: #1565c0;
}

.fab-popup-item.baghdad .fab-popup-value {
  color: #c62828;
}

.fab-popup-item.due .fab-popup-value {
  color: #2e7d32;
}

.fab-popup-currency {
  font-size: 11px;
  color: #888;
}

/* Responsive */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    text-align: center;
  }
  .pieces-grid {
    grid-template-columns: 1fr;
  }
  .piece-actions .btn {
    font-size: 12px;
    padding: 8px 10px;
  }
}
